Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

clipanion

Package Overview
Dependencies
0
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.4.3 to 2.4.4

5

lib/index.d.ts

@@ -35,3 +35,4 @@ /// <reference types="node" />

};
type Callback<T extends string> = T | [T, ...any[]];
type Callback<T extends string> = T | [
];
declare const tests: {

@@ -457,3 +458,3 @@ always: () => boolean;

*/
from<Context extends BaseContext = BaseContext>(commandClasses: CommandClass<Context>[], options?: Partial<CliOptions$0>): Cli<Context>;
static from<Context extends BaseContext = BaseContext>(commandClasses: CommandClass<Context>[], options?: Partial<CliOptions$0>): Cli<Context>;
constructor({ binaryLabel, binaryName: binaryNameOpt, binaryVersion, enableColors }?: Partial<CliOptions$0>);

@@ -460,0 +461,0 @@ /**

11

lib/index.js

@@ -623,3 +623,3 @@ 'use strict';

if (state.selectedIndex === HELP_COMMAND_INDEX) {
helps.push(...state.options);
helps.push(state);
}

@@ -635,5 +635,5 @@ else {

ignoreOptions: false,
path: [],
path: findCommonPrefix(...helps.map(state => state.path)),
positionals: [],
options: helps,
options: helps.reduce((options, state) => options.concat(state.options), []),
remainder: null,

@@ -645,2 +645,7 @@ selectedIndex: HELP_COMMAND_INDEX,

}
function findCommonPrefix(firstPath, secondPath, ...rest) {
if (secondPath === undefined)
return Array.from(firstPath);
return findCommonPrefix(firstPath.filter((segment, i) => segment === secondPath[i]), ...rest);
}
function makeNode() {

@@ -647,0 +652,0 @@ return {

{
"name": "clipanion",
"version": "2.4.3",
"version": "2.4.4",
"main": "lib/index",

@@ -24,3 +24,3 @@ "license": "MIT",

"tslib": "^2.0.0",
"typescript": "^3.9.5",
"typescript": "4.0.0-dev.20200729",
"yup": "^0.29.1"

@@ -27,0 +27,0 @@ },

@@ -112,24 +112,111 @@ # <img src="./logo.svg" height="25" /> Clipanion

#### `@Command.Path(segment1: string, segment2: string, ...)`
#### `@Command.Path(segment1?: string, segment2?: string, ...)`
Specifies through which CLI path should trigger the command. This decorator can only be set on the `execute` function itself, as it isn't linked to specific options.
Specifies through which CLI path should trigger the command.
**This decorator can only be set on the `execute` function itself**, as it isn't linked to specific options.
```ts
class RunCommand extends Command {
@Command.Path(segment1, segment2, segment3)
async execute() {
// ...
}
}
```
Generates:
```bash
run segment1 segment2 segment3
```
Note that you can add as many paths as you want to a single command. By default it will be connected on the main entry point (empty path), but if you add even one explicit path this behavior will be disabled. If you still want the command to be available on both a named path and as a default entry point (for example `yarn` which is an alias for `yarn install`), simply call the decorator without segments:
```ts
@Command.Path(`install`)
@Command.Path()
async execute() {
// ...
class YarnCommand extends Command {
@Command.Path(`install`)
@Command.Path()
async execute() {
// ...
}
}
```
Generates:
```bash
yarn install
# or
yarn
```
#### `@Command.String({required?: boolean})`
Specifies that the command accepts a positional argument. By default it will be required, but this can be toggled off. Note that Clipanion supports required positional arguments both at the beginning and the end of the positional argument list (which allows you to build CLI for things like `cp`).
Specifies that the command accepts a positional argument. By default it will be required, but this can be toggled off.
```ts
class RunCommand extends Command {
@Command.String()
public foo?: string;
}
```
Generates:
```bash
run <ARG>
# => foo = ARG
```
Note that Clipanion supports required positional arguments both at the beginning and the end of the positional argument list (which allows you to build CLI for things like `cp`).
```ts
class RunCommand extends Command {
@Command.String()
public foo?: string;
@Command.String({required: true})
public bar!: string;
}
```
Generates:
```bash
run value1 value2
# => foo = value1
# => bar = value2
run value
# => foo = undefined
# => bar = value
run
# invalid
```
#### `@Command.String(optionNames: string, {tolerateBoolean?: boolean})`
Specifies that the command accepts an option that takes an argument. Arguments can be specified on the command line using either `--foo=ARG` or `--foo ARG`. Because of this, options that accept an argument must, by default, receive one on the CLI (ie `--foo --bar` wouldn't be valid if `--foo` accepts an argument).
Specifies that the command accepts an option that takes an argument. Arguments can be specified on the command line using either `--foo=ARG` or `--foo ARG`.
```ts
class RunCommand extends Command {
@Command.String('--foo,-f')
public bar?: string;
}
```
Generates:
```bash
run --foo <ARG>
run --foo=<ARG>
run -f <ARG>
run -f=<ARG>
# => bar = ARG
```
Be careful, by default, options that accept an argument must receive one on the CLI (ie `--foo --bar` wouldn't be valid if `--foo` accepts an argument).
This behaviour can be toggled off if the `tolerateBoolean` option is set. In this case, the option will act like a boolean flag if it doesn't have a value. Note that with this option on, arguments values can only be specified using the `--foo=ARG` syntax.

@@ -143,11 +230,15 @@

}
```
Generates:
```bash
run --inspect
=> debug = true
# => debug = true
run --inspect=1234
=> debug = "1234"
# debug = "1234"
run --inspect 1234
=> invalid
# invalid
```

@@ -160,6 +251,36 @@

```ts
class RunCommand extends Command {
@Command.Boolean('--foo')
public bar: boolean;
// ...
}
```
Generates:
```bash
run --foo
# => bar = true
```
#### `@Command.Array(optionNames: string)`
Specifies that the command accepts a set of string arguments (`--arg value1 --arg value2`).
Specifies that the command accepts a set of string arguments.
```ts
class RunCommand extends Command {
@Command.Boolean('--arg')
public values: string[];
// ...
}
```
Generates:
```bash
run --arg value1 --arg value2
# => values = [value1, value2]
```
## Command Help Pages

@@ -166,0 +287,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc