diff --git a/examples/argument.js b/examples/argument.js index 30515e919..cddc2e814 100644 --- a/examples/argument.js +++ b/examples/argument.js @@ -1,24 +1,24 @@ #!/usr/bin/env node -// This example shows specifying the arguments using argument() function. +// 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 repo const program = new Command(); program - .version('0.1.0') - .argument('', 'user to login') - .argument('[password]', 'password for user, if required', 'no password given') - .description('example program for argument') - .action((username, password) => { - console.log('username:', username); - console.log('password:', password); + .name('connect') + .argument('', '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 arguments.js --help -// node arguments.js user -// node arguments.js user secret +// node argument.js --help +// node argument.js main.remote.site +// node argument.js main.remote.site admin diff --git a/examples/arguments.js b/examples/arguments.js deleted file mode 100755 index 4aab3ca73..000000000 --- a/examples/arguments.js +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env node - -// This example shows specifying the arguments for the program to pass to the action handler. - -// const { Command } = require('commander'); // (normal include) -const { Command } = require('../'); // include commander in git clone of commander repo -const program = new Command(); - -program - .version('0.1.0') - .arguments(' [password]') - .description('test command', { - username: 'user to login', - password: 'password for user, if required' - }) - .action((username, password) => { - console.log('username:', username); - console.log('password:', password || 'no password given'); - }); - -program.parse(); - -// Try the following: -// node arguments.js --help -// node arguments.js user -// node arguments.js user secret