UNPKG

@anycli/example-plugin-ts

Version:
66 lines (65 loc) 1.85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const command_1 = require("@anycli/command"); class Hello extends command_1.Command { // this makes the parser not fail when it receives invalid arguments // set it to off if you need to accept variable arguments // static strict = false // entry point of command async run() { const { args, flags } = this.parse(Hello); const name = flags.name || 'world'; this.log(`hello ${name} from hello!`); if (args.file && flags.force) { this.log(`you input ${args.file}`); } } } Hello.title = 'scaffolded command that says hello'; // hide the command from help // can also set hidden on args and flags // static hidden = true // usage is set by default // add your own by setting this variable // can be a string or array // static usage = 'title of command' Hello.description = ` Add a longer description here ... ... `; Hello.examples = [ `$ example-plugin-ts hello hello world from hello! `, `$ example-plugin-ts hello --name myname hello myname from hello! `, '$ example-plugin-ts hello file outputs "hello world!" to file', '$ example-plugin-ts hello --force', '$ example-plugin-ts hello --help', ]; // allow running this command by running `$ example-plugin-ts foobar` // static aliases = ['foobar'] Hello.flags = { // flag with a value (-n, --name=VALUE) name: command_1.flags.string({ char: 'n', description: 'name to print', hidden: false, required: false, multiple: false, }), // flag with no value (-f, --force) force: command_1.flags.boolean({ char: 'f', }), }; Hello.args = [ { name: 'file', required: false, description: 'file to output', }, ]; exports.default = Hello;