# CLI Framework, by Ionic The foundation framework of the Ionic CLI. ## Getting Started `index.js`: ```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`: ```javascript #!/usr/bin/env node const run = require('../'); run(process.argv.slice(2), process.env); ``` command line: ```bash $ ./bin/mynewcli $ ./bin/mynewcli version $ ./bin/mynewcli version --help ```
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
lib | Folder | 0755 |
|
|
utils | Folder | 0755 |
|
|
CHANGELOG.md | File | 16.81 KB | 0644 |
|
LICENSE | File | 1.05 KB | 0644 |
|
README.md | File | 1014 B | 0644 |
|
definitions.d.ts | File | 6.95 KB | 0644 |
|
definitions.js | File | 77 B | 0644 |
|
errors.d.ts | File | 1.12 KB | 0644 |
|
errors.js | File | 1.93 KB | 0644 |
|
guards.d.ts | File | 1.01 KB | 0644 |
|
guards.js | File | 1.28 KB | 0644 |
|
index.d.ts | File | 80 B | 0644 |
|
index.js | File | 269 B | 0644 |
|
package.json | File | 5.78 KB | 0644 |
|