Command line framework for deno 🦕 Including Commandline-Interfaces, Prompts, CLI-Table, Arguments Parser and more...
MIT License
Bot releases are hidden (Show)
command: execute command action after option action is called (#285) (9170a65)
Prior to v0.20.0, when an option action was executed, the command action was not executed. Since v0.20.0, this has changed. The command action is now executed by default. Only standalone options do not execute the command actions (for more informations see the docs).
await new Command<void>()
.env<{ outputFile?: string }>(
"CC_OUTPUT_FILE=<value:string>",
"The output file.",
{ prefix: "CC_" },
)
.option<{ outputFile?: string }>(
"--output-file <value:string>",
"The output file.",
)
.action((options) => console.log(options.outputFile))
.parse();
$ CC_OUTPUT_FILE=foo.txt deno run example.ts
foo.txt
$ CC_OUTPUT_FILE=foo.txt deno run example.ts --output-file bar.txt
bar.txt
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");
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: allow numbers for completions (#195) (f30b3af)
command,flags: add integer type (#190) (2cc7e57)
cmd.option("-a, --amount <amount:integer>");
keycode: add code property to parse result (#182) (366683f)
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>",
});
Table.chars()
method to set global default table characters (#107) (fec09df)