@flatjs/cli
v2.1.12
Published
A tool the modern for rapidly building command line flatjs apps
Downloads
684
Readme
@flatjs/cli
A tool the modern for rapidly building command line flatjs apps
Install globally
npm i -g @flatjs/cli
Module/Programmatic Usage
yarn add @flatjs/cli
Add this package to package dependencies linked to your app, just import them like regular packages:
import { bootstrap } from '@flatjs/cli';
bootstrap().then((cli) => {
// Register customized plugins chain.
cli.register(pluginA).register(pluginB);
// Parse progress arguments.
cli.parse(process.argv.slice(2));
});
Create a custom flatjs-based plugin chain e.g. flat test
- flatjs-cli-plugin-
test
/package.json"type": "module", "exports": { ".": { "import": "./index.js" }, "./package.json": "./package.json" },
- flatjs-cli-plugin-
test
/src/index.ts
import type { CommandArgv } from '@armit/commander';
import { AbstractHandler, createCommand } from '@armit/commander';
type TestCmdArgs = CommandArgv<{
test: number;
}>;
class CmdTestHandle extends AbstractHandler<TestCmdArgs> {
handle(): void | Promise<void> {
console.log('this is test command handle');
this.logger.debug('this is debug message for test command');
}
}
const cmdTest = createCommand(
'test',
{
command: 'test',
describe: 'Display flatjs project details.',
builder: (yargs) => {
return yargs.example(`$0 cmd test `, 'cli testing').option('test', {
type: 'number',
alias: 't',
default: true,
describe: `cli option test describe`,
});
},
},
CmdTestHandle
);
// As default export
export default cmdTest;
Contributing
Contributions are happily accepted. I respond to all PR's and can offer guidance on where to make changes. For contributing tips see CONTRIBUTING.md