mirror of
https://github.com/rjNemo/deno_hello
synced 2026-06-06 01:56:40 +00:00
refactor: cli
This commit is contained in:
parent
664e62b1b1
commit
5a7dc56b51
1 changed files with 9 additions and 10 deletions
19
src/index.ts
19
src/index.ts
|
|
@ -10,17 +10,16 @@ const start = async () => {
|
|||
console.log("👉 ");
|
||||
|
||||
for await (const line of readLines(Deno.stdin)) {
|
||||
switch (line.trim()) {
|
||||
case "": {
|
||||
console.log(sayRandomHello());
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
const id = new ID(parseInt(line.trim(), 10));
|
||||
console.log(sayHello(id));
|
||||
}
|
||||
const value = line.trim();
|
||||
|
||||
if (value === "") {
|
||||
console.log(sayRandomHello());
|
||||
} else if (value === "quit") {
|
||||
return;
|
||||
} else {
|
||||
const id = new ID(parseInt(value, 10));
|
||||
console.log(sayHello(id));
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue