Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

command-line-interface

Package Overview
Dependencies
Maintainers
4
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

command-line-interface - npm Package Compare versions

Comparing version 3.3.0 to 3.4.0

1

build/lib/addHelpCommandToCli.js

@@ -9,2 +9,3 @@ "use strict";

description: rootCommand.description,
remarks: rootCommand.remarks,
optionDefinitions: [

@@ -11,0 +12,0 @@ ...rootCommand.optionDefinitions

@@ -6,2 +6,3 @@ import { CommandHandle } from './CommandHandle';

description: string;
remarks?: string;
optionDefinitions: OptionDefinition[];

@@ -8,0 +9,0 @@ ignoreUnknownOptions?: boolean;

4

build/lib/getCommandByPath.js

@@ -9,7 +9,7 @@ "use strict";

}
for (const pathElem of commandPath.slice(1)) {
for (const pathElement of commandPath.slice(1)) {
if (command.subcommands === undefined) {
throw new errors_1.errors.CommandNotFound();
}
command = command.subcommands[pathElem];
command = command.subcommands[pathElement];
if (command === undefined) {

@@ -16,0 +16,0 @@ throw new errors_1.errors.CommandNotFound();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -6,2 +9,3 @@ const convertOptionDefinition_1 = require("../convertOptionDefinition");

const getCommandSynopsis_1 = require("./getCommandSynopsis");
const strip_indent_1 = __importDefault(require("strip-indent"));
const getCommandLineUsageConfiguration = function ({ rootCommand, commandPath }) {

@@ -15,4 +19,3 @@ const commandsInPath = getCommandsByPath_1.getCommandsByPath({ rootCommand, commandPath });

content: [command.description]
},
{
}, {
header: 'Synopsis',

@@ -45,4 +48,10 @@ content: [synopsis]

}
if (command.remarks) {
usage.push({
header: 'Remarks',
content: [strip_indent_1.default(command.remarks).trim()]
});
}
return usage;
};
exports.getCommandLineUsageConfiguration = getCommandLineUsageConfiguration;

@@ -0,1 +1,8 @@

# [3.4.0](https://github.com/thenativeweb/command-line-interface/compare/3.3.0...3.4.0) (2020-02-10)
### Features
* Support remarks on commands. ([#31](https://github.com/thenativeweb/command-line-interface/issues/31)) ([a0074ae](https://github.com/thenativeweb/command-line-interface/commit/a0074aee4368f23d74df14f21361b3efcf1a9e04))
# [3.3.0](https://github.com/thenativeweb/command-line-interface/compare/3.2.2...3.3.0) (2020-02-10)

@@ -2,0 +9,0 @@

@@ -10,2 +10,3 @@ import { Command } from './elements/Command';

description: rootCommand.description,
remarks: rootCommand.remarks,
optionDefinitions: [

@@ -12,0 +13,0 @@ ...rootCommand.optionDefinitions

@@ -9,2 +9,4 @@ import { CommandHandle } from './CommandHandle';

remarks?: string;
optionDefinitions: OptionDefinition[];

@@ -11,0 +13,0 @@

@@ -15,7 +15,7 @@ import { Command } from './elements/Command';

for (const pathElem of commandPath.slice(1)) {
for (const pathElement of commandPath.slice(1)) {
if (command.subcommands === undefined) {
throw new errors.CommandNotFound();
}
command = command.subcommands[pathElem];
command = command.subcommands[pathElement];
if (command === undefined) {

@@ -22,0 +22,0 @@ throw new errors.CommandNotFound();

@@ -6,2 +6,3 @@ import { Command } from '../elements/Command';

import { getCommandSynopsis } from './getCommandSynopsis';
import stripIndent from 'strip-indent';
import commandLineUsage, { Section } from 'command-line-usage';

@@ -22,4 +23,3 @@

content: [ command.description ]
},
{
}, {
header: 'Synopsis',

@@ -31,30 +31,33 @@ content: [ synopsis ]

if (command.optionDefinitions.length > 0) {
usage.push(
{
header: 'Options',
optionList: command.optionDefinitions.map((optionDefinition): commandLineUsage.OptionDefinition => {
const convertedOptionDefinition = convertOptionDefinition({ optionDefinition });
usage.push({
header: 'Options',
optionList: command.optionDefinitions.map((optionDefinition): commandLineUsage.OptionDefinition => {
const convertedOptionDefinition = convertOptionDefinition({ optionDefinition });
return {
...convertedOptionDefinition,
description: optionDefinition.description,
typeLabel: `{underline ${optionDefinition.parameterName ?? optionDefinition.type}}`
};
})
}
);
return {
...convertedOptionDefinition,
description: optionDefinition.description,
typeLabel: `{underline ${optionDefinition.parameterName ?? optionDefinition.type}}`
};
})
});
}
if (command.subcommands && Object.keys(command.subcommands).length > 0) {
usage.push(
{
header: 'Commands',
content: Object.entries(command.subcommands).map(([ name, subcommand ]): any => ({
name,
description: subcommand.description
}))
}
);
usage.push({
header: 'Commands',
content: Object.entries(command.subcommands).map(([ name, subcommand ]): any => ({
name,
description: subcommand.description
}))
});
}
if (command.remarks) {
usage.push({
header: 'Remarks',
content: [ stripIndent(command.remarks).trim() ]
});
}
return usage;

@@ -61,0 +64,0 @@ };

{
"name": "command-line-interface",
"version": "3.3.0",
"version": "3.4.0",
"description": "command-line-interface is a foundation for CLI applications.",

@@ -22,3 +22,4 @@ "contributors": [

"defekt": "5.0.1",
"string-similarity": "4.0.1"
"string-similarity": "4.0.1",
"strip-indent": "3.0.0"
},

@@ -29,2 +30,3 @@ "devDependencies": {

"@types/command-line-usage": "5.0.1",
"@types/common-tags": "1.8.0",
"@types/sinon": "7.5.1",

@@ -31,0 +33,0 @@ "@types/string-similarity": "3.0.0",

@@ -35,3 +35,3 @@ # command-line-interface

Before being able to run a CLI, you must create a command. A command represents a piece of logic callable from the command line. In that sense, a command has a `name`, a `description`, a list of `optionDefinitions`, and a `handle` function:
Before being able to run a CLI, you must create a command. A command represents a piece of logic callable from the command line. In that sense, a command has a `name`, a `description`, a list of `optionDefinitions`, and a `handle` function. Optionally, you may also specify `remarks` to show in the command's help:

@@ -42,2 +42,5 @@ ```javascript

description: 'Say hello on the command line.',
remarks: `
If you don't specify a name, 'Jane' will be used as default.
`,

@@ -44,0 +47,0 @@ optionDefinitions: [

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc