5.1.9 • Published 1 year ago

@navify/cli-framework v5.1.9

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

CLI Framework, by Navify

The foundation framework of the Navify CLI.

Getting Started

index.js:

const { Command, CommandMap, Namespace, execute } = require('@navify/cli-framework');

class VersionCommand extends Command {
  async getMetadata() {
    return {
      name: 'version',
      summary: 'Print CLI version',
    };
  }

  async run() {
    console.log('1.0.0');
  }
}

class RootNamespace extends Namespace {
  async getMetadata() {
    return {
      name: 'mynewcli',
      summary: 'A cool CLI that prints its own version',
    };
  }

  async getCommands() {
    return new CommandMap([['version', async () => new VersionCommand(this)]]);
  }
}

module.exports = async function(argv, env) {
  await execute({ namespace: new RootNamespace(), argv, env });
}

bin/mynewcli:

#!/usr/bin/env node

const run = require('../');
run(process.argv.slice(2), process.env);

command line:

$ ./bin/mynewcli
$ ./bin/mynewcli version
$ ./bin/mynewcli version --help