Skip to content
Myr

pm

This file

Path

examples/pm

27 lines · 860 bytes

Last changed by

Merge pull request #391 from zhiyelee/newversionZhiye Libefore adoption4dae21d

History of this file

Take it

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

lines 1–9why, 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')

Merge pull request #391 from zhiyelee/newversionZhiye Libefore adoption4dae21d

line 10why, one step back
10 .command('publish', 'publish the package')

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

lines 11–27why, one step back
11 .parse(process.argv);
1213// here .command() is invoked with a description,14// and no .action(callback) calls to handle sub-commands.15// this tells commander that you're going to use separate16// executables for sub-commands, much like git(1) and other17// popular tools.1819// here only ./pm-install(1) is implemented, however you20// would define ./pm-search(1) and ./pm-list(1) etc.2122// Try the following:23// ./examples/pm24// ./examples/pm help install25// ./examples/pm install -h26// ./examples/pm install foo bar baz27// ./examples/pm install foo bar baz --force