Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions examples/argument.js
Original file line number Diff line number Diff line change
@@ -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('<username>', '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('<server>', 'connect to the specified server')
.argument('[user]', 'user account for connection', 'guest')
.description('example program with argument descriptions')
.action((server, user) => {
console.log('username:', 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
26 changes: 0 additions & 26 deletions examples/arguments.js

This file was deleted.