Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(prompt): add cbreak option (#106)
- Loading branch information
1 parent
ed588e2
commit a637b54
Showing
5 changed files
with
83 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env -S deno run --unstable | ||
|
||
import { tty } from "../../ansi/tty.ts"; | ||
import { Toggle } from "../../prompt/toggle.ts"; | ||
|
||
const sig = Deno.signals.interrupt(); | ||
(async () => { | ||
for await (const _ of sig) { | ||
tty.cursorShow(); | ||
console.log("\nSigint received. Exiting deno process!"); | ||
Deno.exit(1); | ||
} | ||
})(); | ||
|
||
const confirmed: boolean = await Toggle.prompt({ | ||
message: "Please confirm", | ||
cbreak: true, | ||
}); | ||
|
||
console.log({ confirmed }); | ||
|
||
sig.dispose(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters