Skip to content
Myr

pm

This file

Path

examples/pm

26 lines · 815 bytes

Last changed by

add git-style executable subcommand support. Closes #94TJ Holowaychukbefore adoption21b4169

History of this file

Take it

add git-style executable subcommand support. Closes #94TJ Holowaychukbefore adoption21b4169

lines 1–26why, one step back
1#!/usr/bin/env node
23var program = require('..');45program6 .version('0.0.1')7 .command('install [name]', 'install one or more packages')8 .command('search [query]', 'search with optional query')9 .command('list', 'list packages installed')10 .parse(process.argv);1112// here .command() is invoked with a description,13// and no .action(callback) calls to handle sub-commands.14// this tells commander that you're going to use separate15// executables for sub-commands, much like git(1) and other16// popular tools.1718// here only ./pm-install(1) is implemented, however you19// would define ./pm-search(1) and ./pm-list(1) etc.2021// Try the following:22// ./examples/pm23// ./examples/pm help install24// ./examples/pm install -h25// ./examples/pm install foo bar baz26// ./examples/pm install foo bar baz --force