v0.19.0
BREAKING CHANGES
-
keycode: refactor keycode module (#186) (4ac2719)
Before:
const key: KeyEvent = KeyCode.parse( "\x1b[A\x1b[B\x1b[C\x1b[D\x1b[E\x1b[F\x1b[H", );
After:
const key: KeyCode = parse("\x1b[A\x1b[B\x1b[C\x1b[D\x1b[E\x1b[F\x1b[H");
Features
-
command: add exitCode option to ValidationError (#201) (d4c0f12)
throw new ValidationError("Some validation error", { exitCode: 2 });
-
command: add enum type (#197) (36289a2)
cmd.type("log-level", new EnumType(["debug", "info", 0, 1])) .option("-L, --log-level <level:log-level>");
-
command: improve support for generic custom types (#191) (59b1a93)
const color = new EnumType(["red", "blue", "yellow"]); cmd.type("color", color) // you can pass the type .option<{ color: typeof color }>("-c, --color <name:color>");
-
command: add upgrade command (#203) (348f743)
// single registry with default options cmd.command( "upgrade", new UpgradeCommand({ provider: new DenoLandProvider(), }), ); // multi registry with custom options cmd.command( "upgrade", new UpgradeCommand({ main: "cli.ts", args: ["--allow-net", "--unstable"], provider: [ new DenoLandProvider({ name: "cliffy" }), new NestLandProvider({ name: "cliffy" }), new GithubProvider({ repository: "c4spar/deno-cliffy" }), ], }), );
-
command: add values method to types to show possible values in help text (#202) (143eb1b, 045c56e)
-
command,flags: add integer type (#190) (2cc7e57)
cmd.option("-a, --amount <amount:integer>");
-
keypress: add keypress module (#187) (5acf5db)
// promise const event: KeyPressEvent = await keypress(); // events keypress().addEventListener((event: KeyPressEvent) => { console.log("event:", event); if (event.ctrlKey && event.key === "c") { keypress().dispose(); } }); // async iterator for await (const event: KeyPressEvent of keypress()) { console.log("event:", event); if (event.ctrlKey && event.key === "c") { break; } }
-
prompt: add id option to automatically save suggestions to local storage (#204) (28f25bd)
await Input.prompt({ message: "Enter your name", id: "<local-storage-key>", });
Bug Fixes
- command,flags: value handler not called for default value if option is not defined on commandline (ef3df5e)
- keycode: fix esc key and sequence property for escaped keys (b9eb39b)
- table: fix getBody and hasHeaderBorder methods (2d65cc8)
Code Refactoring
- command: add CompleteHandlerResult type (#200) (ade3c3d)
- command: remove unnecessary dependency (#199) (b26f07c)
- flags: refactor number type (#196) (9b57f54)
- flags: refactor error message for boolean and number types (#189) (2a19c34)
- keycode: refactor special key handling (7aaaec4)
- prompt: enable raw mode only if stdin is a tty (#183) (83c644a)
Chore
- ci: upgrade to [email protected] (7a8e3dd)
- upgrade: deno/std v0.97.0 (#207) (37dc946)
Unit/Integration Tests
- flags: fix value tests (5ec86e8)
- prompt: add integration tests (#172) (0031490)
- table: add more tests (3dd6315)