@ionic/cli-framework
TypeScript icon, indicating that this package has built-in type declarations

6.0.1 • Public • Published

CLI Framework, by Ionic

The foundation framework of the Ionic CLI.

Getting Started

index.js:

const { Command, CommandMap, Namespace, execute } = require('@ionic/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

/@ionic/cli-framework/

    Package Sidebar

    Install

    npm i @ionic/cli-framework

    Weekly Downloads

    83,321

    Version

    6.0.1

    License

    MIT

    Unpacked Size

    144 kB

    Total Files

    40

    Last publish

    Collaborators

    • ionicjs