Socket
Socket
Sign inDemoInstall

cmdln

Package Overview
Dependencies
5
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.0 to 5.1.0

22

CHANGES.md

@@ -7,2 +7,24 @@ # node-cmdln Changelog

## 5.1.0
- [issue #19] Add `strings` config option to `Cmdln` creation that allows
overriding the strings used in some generated output -- in particular the
help output headers. E.g., one can use:
```javascript
function CLI() {
Cmdln.call(this, {
// ...
strings: {
helpHeaderUsage: 'USAGE',
helpHeaderOptions: 'OPTIONS',
helpHeaderCommands: 'COMMANDS'
}
```
To have the CLI help output use "USAGE" rather than "Usage:", etc.
See https://github.com/trentm/node-cmdln/blob/master/test/cmd/help-header-style.js
for a complete example.
## 5.0.0

@@ -9,0 +31,0 @@

50

lib/cmdln.js

@@ -39,4 +39,32 @@ /*

var DEFAULT_STRINGS = {
helpHeaderUsage: 'Usage:',
helpHeaderOptions: 'Options:',
helpHeaderCommands: 'Commands:'
};
// ---- internal support stuff
function mergeObjects(defaults, provided) {
var k;
var rv = {};
if (defaults) {
for (k in defaults) {
if (defaults[k] !== undefined) {
rv[k] = defaults[k];
}
}
}
if (provided) {
for (k in provided) {
if (provided[k] !== undefined) {
rv[k] = provided[k];
}
}
}
return rv;
}
function indentLines(s, indentation) {

@@ -430,2 +458,12 @@ if (!indentation) {

* ]
* - @param strings {Object} Override the default strings used in
* generated output. This can be used for changing the style of
* help headers, e.g.:
* strings: {
* helpHeaderUsage: 'USAGE:',
* helpHeaderOptions: 'OPTIONS:',
* helpHeaderCommands: 'COMMANDS:'
* }
* See `DEFAULT_STRINGS` in the code for strings that can be overriden.
* The given `strings` can override all, some, or none of the strings.
* - @param options {Array} Custom options (in the format used by

@@ -454,2 +492,3 @@ * [dashdash](https://github.com/trentm/node-dashdash)). If not

assert.optionalObject(config.helpSubcmds, 'config.helpSubcmds');
assert.optionalObject(config.strings, 'config.strings');

@@ -483,2 +522,3 @@ this.name = config.name || this.constructor.name.toLowerCase();

}
this.strings = mergeObjects(DEFAULT_STRINGS, config.strings);

@@ -1006,7 +1046,7 @@ this.optParser = new dashdash.Parser({

if (this.optParser.help) {
lines.push('Options:');
lines.push(this.strings.helpHeaderOptions);
lines.push(this.optParser.help(helpOpts));
}
lines = lines.concat(['Commands:']);
lines = lines.concat([self.strings.helpHeaderCommands]);
// Automatic command line from `this._handlerFromName`.

@@ -1138,3 +1178,5 @@ // TODO: same helpCol as for the opts above, textwrap, etc.

'{{usage}}',
'Usage:\n' + indentLines(synopses.join('\n'))
this.strings.helpHeaderUsage +
'\n' +
indentLines(synopses.join('\n'))
);

@@ -1150,3 +1192,3 @@ }

'{{options}}',
'Options:\n' + parser.help(helpOpts)
this.strings.helpHeaderOptions + '\n' + parser.help(helpOpts)
);

@@ -1153,0 +1195,0 @@ }

2

package.json
{
"name": "cmdln",
"version": "5.0.0",
"version": "5.1.0",
"description": "helper lib for creating CLI tools with subcommands; think `git`, `svn`, `zfs`",

@@ -5,0 +5,0 @@ "author": "Trent Mick (http://trentm.com)",

@@ -5,6 +5,3 @@ `node-cmdln` is a node.js helper lib for creating CLI tools with subcommands

Follow <a href="https://twitter.com/intent/user?screen_name=trentmick" target="_blank">@trentmick</a>
for updates to node-cmdln.
# Usage

@@ -11,0 +8,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc