pm
This file
Path
examples/pm
33 lines · 1.1 KiB
Last changed by
Merge pull request #1683 from tj/release/9.xJohn Geebefore adoption02a124c
History of this fileTake it
1#!/usr/bin/env node23// const { Command } = require('commander'); // (normal include)4const { Command } = require('../'); // include commander in git clone of commander repo5const program = new Command();67// Example of subcommands which are implemented as stand-alone executable files.8//9// When `.command()` is invoked with a description argument,10// this tells Commander that you're going to use a stand-alone executable for the subcommand.11//12// Only `install` and `list` are implemented, see pm-install and pm-list.js1314program15 .name('pm')16 .version('0.0.1')17 .description('Fake package manager')18 .command('install [name]', 'install one or more packages').alias('i')19 .command('search [query]', 'search with optional query').alias('s')20 .command('update', 'update installed packages', { executableFile: 'myUpdateSubCommand' })21 .command('list', 'list packages installed', { isDefault: true });2223program.parse(process.argv);2425// Try the following on macOS or Linux:26// ./examples/pm27//28// Try the following:29// node pm30// node pm help install31// node pm install -h32// node pm install foo bar baz33// node pm install foo bar baz --force