Skip to content
Myr

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 file

Take it

More consistent way of adding command arguments (#1490)John Geebefore adoptionb286da9

lines 1–2why, one step back
1#!/usr/bin/env node
2

Rework example to avoid graphql warnings (#1719)John Geebefore adoptiona80b984

line 3why, one step back
3// 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 back
4
5// const { Command } = require('commander'); // (normal include)6const { Command } = require('../'); // include commander in git clone of commander repo7const program = new Command();89program

Rework example to avoid graphql warnings (#1719)John Geebefore adoptiona80b984

lines 10–16why, one step back
10 .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 back
17 });
1819program.parse();2021// Try the following:

Rework example to avoid graphql warnings (#1719)John Geebefore adoptiona80b984

lines 22–24why, one step back
22// node argument.js --help
23// node argument.js main.remote.site24// node argument.js main.remote.site admin