Skip to content
Myr

pm

This file

Path

examples/pm

36 lines · 1.0 KiB

Last changed by

Switching to esm-only (#2464)John Geebefore adoptionf4bd470

History of this file

Take it

1#!/usr/bin/env node23import { Command } from 'commander';4const program = new Command();56// Example of subcommands which are implemented as stand-alone executable files.7//8// When `.command()` is invoked with a description argument,9// this tells Commander that you're going to use a stand-alone executable for the subcommand.10//11// Only `install` and `list` are implemented, see pm-install and pm-list.js1213program14  .name('pm')15  .version('0.0.1')16  .description('Fake package manager')17  .command('install [package-names...]', 'install one or more packages')18  .alias('i')19  .command('search [query]', 'search with optional query')20  .alias('s')21  .command('update', 'update installed packages', {22    executableFile: 'myUpdateSubCommand',23  })24  .command('list', 'list packages installed', { isDefault: true });2526program.parse(process.argv);2728// Try the following on macOS or Linux:29//    ./examples/pm30//31// Try the following:32//    node pm33//    node pm help install34//    node pm install -h35//    node pm install foo bar baz36//    node pm install foo bar baz --force