@ricdotnet/cli
v0.2.0
Published
A cli framework to create cli tools.
Downloads
5
Readme
This is still WIP
Configuration
Create a file in your project root and name it clitool.config.ts. You can use the template below.
import { IConfig } from "...";
export const config: IConfig = {
command: 'CLIFramework', // this might be removed
dir: 'commands', // where you store your commands
};
Sample command
import { Command } from '...';
import { ICommand } from '...';
import { Spinner } from '...';
import { Prompt } from '...';
@Command('test') // command name
export class TestCommand implements ICommand {
description: string = 'this command does something'; // description to show on help
private spinner: Spinner;
async run(): Promise<void> {
this.spinner = new Spinner({ spinner: 'braile' });
const name = await Prompt.ask('What is your name?');
this.spinner.start(); // start the spinner
await new Promise((res) => setTimeout(res, 5000)); // a long running task
this.spinner.stop(); // stop the spinner
const surname = await Prompt.ask('What is your surname?');
this.spinner.changeSpinner('circleNumbers'); // the user can change the spinner
this.spinner.start(); // start the spinner
await new Promise((res) => setTimeout(res, 5000)); // a long running task
this.spinner.stop(); // stop the spinner
console.log(`Hello ${name} ${surname}!`);
}
}