argument.js
This file
Path
examples/argument.js
24 lines · 759 bytes · JavaScript
Last changed by
Rework example to avoid graphql warnings (#1719)John Geebefore adoptiona80b984
History of this fileTake it
12345678910111213141516171819202122232425#!/usr/bin/env node
// This example shows specifying the command arguments using argument() function.
// const { Command } = require('commander'); // (normal include)const { Command } = require('../'); // include commander in git clone of commander repoconst program = new Command();
program .name('connect') .argument('<server>', 'connect to the specified server') .argument('[user]', 'user account for connection', 'guest') .description('Example program with argument descriptions') .action((server, user) => { console.log('server:', server); console.log('user:', user); });
program.parse();
// Try the following:// node argument.js --help// node argument.js main.remote.site// node argument.js main.remote.site admin