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
More consistent way of adding command arguments (#1490)John Geebefore adoptionb286da9
lines 1–2why, one step back1#!/usr/bin/env node2Rework example to avoid graphql warnings (#1719)John Geebefore adoptiona80b984
line 3why, one step back3// This example shows specifying the command arguments using argument() function.More consistent way of adding command arguments (#1490)John Geebefore adoptionb286da9
lines 4–9why, one step back45// const { Command } = require('commander'); // (normal include)6const { Command } = require('../'); // include commander in git clone of commander repo7const program = new Command();89programRework example to avoid graphql warnings (#1719)John Geebefore adoptiona80b984
lines 10–16why, one step back10 .name('connect')11 .argument('<server>', 'connect to the specified server')12 .argument('[user]', 'user account for connection', 'guest')13 .description('Example program with argument descriptions')14 .action((server, user) => {15 console.log('server:', server);16 console.log('user:', user);More consistent way of adding command arguments (#1490)John Geebefore adoptionb286da9
lines 17–21why, one step back17 });1819program.parse();2021// Try the following:Rework example to avoid graphql warnings (#1719)John Geebefore adoptiona80b984
lines 22–24why, one step back22// node argument.js --help23// node argument.js main.remote.site24// node argument.js main.remote.site admin