@ufo-soft/caelus-cli
A caelus registry as a command-line interface. Each command becomes a subcommand and each parameter an option, all derived from the registry, via commander.
sh
npm install @ufo-soft/caelus @ufo-soft/caelus-clits
import { cli } from '@ufo-soft/caelus-cli'
process.exitCode = await cli(registry, process.argv.slice(2), 'todo')sh
$ todo add --text 'write it down'
$ todo --helpcli resolves to the exit code rather than exiting, so the caller decides what to do with it.
- A
stringorintegerparameter is a required--name <value>option; an integer is checked before the handler runs. - A
booleanparameter is a--nameflag, false when absent. - An
okoutcome prints its data, if any: a string as-is, anything else as JSON. - A
failedoutcome prints its reason to stderr and exits non-zero.
Output goes to process.stdout and process.stderr unless an Io is passed as the fourth argument.