@je-es/cli
v1.0.0
Published
A powerful and user-friendly tool for building CLI applications effortlessly.
Downloads
10
Maintainers
Readme
@je-es/cli
A powerful and user-friendly tool for building CLI applications effortlessly.
📥 Install
npm i @je-es/cli
🌟 Syntax
import { cli, t_cli } from '@je-es/cli';
🔥 Usage
This is just a simple example to cover different use cases, you are free to create whatever you want !
// The cli-application options const options : t_cli = { info : { name : 'people', desc : 'a simple cli application to add people', vers : '1.0.0' }, actions : { 'add' : { flag : '-a', alias : '--add', args : ['name', 'age'], requires : ['career'], options : ['force'], callback : ( args: { name: string, age: string, career: string, force?: boolean } ) => { // is this person is already registered ? if( ... ) { // IF not forced, throw an error if( !force ) { throw new Error('This person is already registered'); } // Remove the person (forcefully) else { ... } } // Register the new person ... } }, 'career' : { alias : '--career', args : ['career'], }, 'force' : { flag : '-f', } } };
// Initialize the CLI with the options cli(options);
NOTES
At the beginning of the main file, add the following line:
#!/usr/bin/env node ...
In the
package.json
file, add the following option :{ "bin" : { "people" : "./dist/main.js" // ^ ^ // name path }, }
Run the application
npx people --add Maysara 24 --career Developer -f
IF there are any syntax errors or missing arguments, an error will be thrown, see the API to learn more.
Documentation
Made with ❤ by Maysara Elshewehy