A high-level build target for Command Line Interfaces.
Use it to build (and publish) Command Line Interfaces.
Example:
const cli = new x9.build.Cli({});
Some Highlights:
- Type Driven: CLI commands, parameters and docs/help are automatically derived from TypeScript type information. This means your CLI interface definition plays nicely with the rest of your code. It can be easily refactored and doesn’t fall out of sync.
- Highly Optimized: The resulting package/bundle is optimized for CLI usage (ex: it uses lazy loading of modules for ultra-snappy peformance). This is done transparenly by the compiler, and it doesn’t require you to change the way you code
- Great Developer Experience: Since x9 knows this is a CLI (not just a regular node.js program), it is able to provide specialized support for testing, playgrounds, and other dev-time features.
Example
// logic goes here
function main() {
console.log("Hello World!")
}
// build definition
const cli = new Cli({ main, command: "hello", alias: "hh" })
// export tasks so you can call then from the command line
export function publish(){
// ...
}
Declaring your CLI interface using Types