@sirian/console

The Console component allows you to create command-line commands

Usage no npm install needed!

<script type="module">
  import sirianConsole from 'https://cdn.skypack.dev/@sirian/console';
</script>

README

Console

Npm version LICENSE

Install

npm install @sirian/console

Example

import {Application, Argument, Command, CommandDefinition} from "@sirian/console";

class HelloCommand extends Command {
    static configure(definition: CommandDefinition) {
        definition
            .setDescription("Simple command example")
            .setArguments({
                name: new Argument({
                    defaultValue: "Nobody",
                    required: false,
                }),
            });
    }

    execute() {
        const io = this.io;
        const name = io.input.getArgument("name");
        io.success("Great, you did it!");
        io.writeln(`Hello <info>${name}</info>!`);
    }
}

const app = new Application({
    name: "Example",
    commands: [
        HelloCommand
    ]
});
app.run();