docs
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 2a175d7 · Browse files · 2 files·+9 added−9 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+9 added−9 removed
- other:+9 added−9 removed
Provenance
- Commit
236ef92- Tree
fb9d1ec- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
2a175d7
2 files changed+9 added−9 removed
modified:lib/commander.js+8 added-8 removed
43 unmodified lines44 this.required = ~flags.indexOf('<');45 this.optional = ~flags.indexOf('[');46 this.bool = !~flags.indexOf('-no-');47 flags = flags.split(/[ ,|]+/)48- this.small = flags.shift();49- this.large = flags.shift();48+ this.short = flags.shift();49+ this.long = flags.shift();50 this.description = description;51 }52 53 /**3 unmodified lines57 * @api private58 */59 60 Option.prototype.name = function(){61- return this.large61+ return this.long62 .replace('--', '')63 .replace('no-', '');64 };65 66 /**67- * Check if `arg` matches the small or large flag.67+ * Check if `arg` matches the short or long flag.68 *69 * @param {String} arg70 * @return {Boolean}71 * @api private72 */73 74 Option.prototype.is = function(arg){75- return arg == this.small76- || arg == this.large;75+ return arg == this.short76+ || arg == this.long;77 };78 79 /**80 * Initialize a new `Command`.131 unmodified lines212 /**213 * Define option with `flags`, `description` and optional214 * coercion `fn`. 215 *216- * The `flags` string should contain both the small and large flags,216+ * The `flags` string should contain both the short and long flags,217 * separated by comma, a pipe or space. The following are all valid218 * all will output this way when `--help` is used.219 *220 * "-p, --pepper"88 unmodified lines309 return this.parseArgs(this.parseOptions(this.normalize(argv)));310 };311 312 /**313- * Normalize `args`, splitting joined small flags. For example313+ * Normalize `args`, splitting joined short flags. For example314 * the arg "-abc" is equivalent to "-a -b -c".315 *316 * @param {Array} args317 * @return {Array}485 unmodified linesmodified:Readme.md+1 added-1 removed
33 unmodified lines34353637383839404142125 unmodified linesExpand all33 unmodified linesif (program.bbq) console.log(' - bbq');console.log(' - %s cheese', program.cheese || 'marble');```
Small flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`.
## Automated --help
The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free:125 unmodified linesExpand all