init
This commit is contained in:
24
node_modules/@rushstack/ts-command-line/LICENSE
generated
vendored
Normal file
24
node_modules/@rushstack/ts-command-line/LICENSE
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
@rushstack/ts-command-line
|
||||
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
251
node_modules/@rushstack/ts-command-line/README.md
generated
vendored
Normal file
251
node_modules/@rushstack/ts-command-line/README.md
generated
vendored
Normal file
@ -0,0 +1,251 @@
|
||||
# ts-command-line
|
||||
|
||||
This library helps you create professional command-line tools using TypeScript. By "professional", we mean:
|
||||
|
||||
- **no gotchas for users**: Seems obvious, but try typing "`npm install --save-dex`" instead of "`npm install --save-dev`" sometime. The command seems to execute successfully, but it doesn't save anything! The misspelled flag was silently ignored. This lack of rigor plagues many familiar Node.js tools and can be confusing and frustrating. For a great user experience, a command line tool should always be strict about its syntax.
|
||||
|
||||
- **no gotchas for developers**: Many command-line libraries store their parsed data in a simple JavaScript object. This is convenient for small projects. But suppose a large project has many different source files that define and read parameters. If you try to read `data['output-dir']` when it wasn't defined, or if you misspell the key name, your tool will silently behave as if the parameter was omitted. And is `data['max-count']` a string or a number? Hard to tell! We solve this by modeling each parameter kind as a real TypeScript class.
|
||||
|
||||
- **simple by design**: Making a CLI is similar to making a graphical UI -- some people have a knack for clean and intuitive designs, but your average developer... needs some help. :-) Keeping things simple is the best help. **ts-command-line** intentionally provides a minimalist set of CLI building blocks that encourage simple designs. If your app has lots of knobs and switches, we recommend NOT to design a complex CLI with hundreds of parameters. Move those options into a commented config file with a published JSON schema.
|
||||
|
||||
- **automatic documentation**: Some command-line libraries treat the `--help` docs as someone else's job. **ts-command-line** requires each every parameter to follow a standardized naming pattern and have a documentation string. It will automatically generate the `--help` docs for you. If you like to write long paragraphs, no problem -- they will be word-wrapped correctly. *[golf clap]*
|
||||
|
||||
- **structure and extensibility**: Instead of a simple function chain, **ts-command-line** provides a "scaffold" pattern that makes it easy to find and understand the command-line implementation for any tool project. The scaffold model is generally recommended, but there's also a "dynamic" model if you need it. See below for examples.
|
||||
|
||||
- **environment variable mappings**: Any CLI parameter can be associated with an environment variable. If the parameter is not explicitly provided, the value from the environment will be used. The associated environment variables are automatically documented in the `--help`.
|
||||
|
||||
Internally, the implementation is based on [argparse](https://www.npmjs.com/package/argparse) and the Python approach to command-lines.
|
||||
|
||||
Compared to other libraries, **ts-command-line** doesn't provide zillions of custom syntaxes and bells and whistles. Instead it aims to be a simple, consistent, and professional solution for your command-line tool. Give it a try!
|
||||
|
||||
### Some Terminology
|
||||
|
||||
Suppose that we want to parse a command-line like this:
|
||||
|
||||
```
|
||||
widget --verbose push --force --max-count 123
|
||||
```
|
||||
|
||||
In this example, we can identify the following components:
|
||||
|
||||
- The **tool name** in this example is `widget`. This is the name of your Node.js bin script.
|
||||
- The **parameters** are `--verbose`, `--force`, and `--max-count`.
|
||||
- The value "123" is the **argument** for the `--max-count` integer parameter. (Flags don't have arguments, because their value is determined by whether the flag was provided or not.)
|
||||
- Similar to Git's command-line, the `push` token is called an **action**. It acts as sub-command with its own unique set of parameters.
|
||||
- The `--verbose` flag is a **global parameter** because it precedes the action name. It affects all actions.
|
||||
- The `--force` flag is an **action parameter** because it comes after the action name. It only applies to that action.
|
||||
|
||||
|
||||
### Parameter Kinds
|
||||
|
||||
Several different kinds of parameters are supported:
|
||||
|
||||
| Parameter Kind | Example | Data Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| flag | `--verbose` | `boolean` | Value is `true` if the flag was specified on the command line, `false` otherwise. |
|
||||
| integer | `--max-retry 3` | `int` | The argument is an integer number |
|
||||
| string | `--title "Hello, world"` | `string` | The argument is a text string. |
|
||||
| choice | `--color red` | `string` | The argument is must be a string from a list of allowed choices (similar to an enum). |
|
||||
| string list | `-o file1.txt -o file2.txt` | `string[]` | The argument is a text string. The parameter can be specified multiple times to build a list. |
|
||||
|
||||
Other parameter kinds could be implemented if requested. That said, keeping your CLI grammar simple and systematic makes it easier for users to learn.
|
||||
|
||||
|
||||
## Scaffold Model
|
||||
|
||||
If your tool uses the scaffold model, you will create subclasses of two abstract base classes: `CommandLineParser` for the overall command-line, and `CommandLineAction` for each action.
|
||||
|
||||
Continuing our example from above, suppose we want to start with a couple simple flags like this:
|
||||
|
||||
```
|
||||
widget --verbose push --force
|
||||
```
|
||||
|
||||
We could define our subclass for the "`push`" action like this:
|
||||
|
||||
```typescript
|
||||
export class PushAction extends CommandLineAction {
|
||||
private _force: CommandLineFlagParameter;
|
||||
private _protocol: CommandLineChoiceParameter;
|
||||
|
||||
public constructor() {
|
||||
super({
|
||||
actionName: 'push',
|
||||
summary: 'Pushes a widget to the service',
|
||||
documentation: 'Here we provide a longer description of how our action works.'
|
||||
});
|
||||
}
|
||||
|
||||
protected onExecute(): Promise<void> { // abstract
|
||||
return BusinessLogic.doTheWork(this._force.value, this._protocol.value || "(none)");
|
||||
}
|
||||
|
||||
protected onDefineParameters(): void { // abstract
|
||||
this._force = this.defineFlagParameter({
|
||||
parameterLongName: '--force',
|
||||
parameterShortName: '-f',
|
||||
description: 'Push and overwrite any existing state'
|
||||
});
|
||||
|
||||
this._protocol = this.defineChoiceParameter({
|
||||
parameterLongName: '--protocol',
|
||||
description: 'Specify the protocol to use',
|
||||
alternatives: ['ftp', 'webdav', 'scp'],
|
||||
environmentVariable: 'WIDGET_PROTOCOL',
|
||||
defaultValue: 'scp'
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then we might define the parser subclass like this:
|
||||
|
||||
```typescript
|
||||
export class WidgetCommandLine extends CommandLineParser {
|
||||
private _verbose: CommandLineFlagParameter;
|
||||
|
||||
public constructor() {
|
||||
super({
|
||||
toolFilename: 'widget',
|
||||
toolDescription: 'The "widget" tool is a code sample for using the @rushstack/ts-command-line library.'
|
||||
});
|
||||
|
||||
this.addAction(new PushAction());
|
||||
}
|
||||
|
||||
protected onDefineParameters(): void { // abstract
|
||||
this._verbose = this.defineFlagParameter({
|
||||
parameterLongName: '--verbose',
|
||||
parameterShortName: '-v',
|
||||
description: 'Show extra logging detail'
|
||||
});
|
||||
}
|
||||
|
||||
protected onExecute(): Promise<void> { // override
|
||||
BusinessLogic.configureLogger(this._verbose.value);
|
||||
return super.onExecute();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To invoke the parser, the application entry point will do something like this:
|
||||
|
||||
```typescript
|
||||
const commandLine: WidgetCommandLine = new WidgetCommandLine();
|
||||
commandLine.execute();
|
||||
```
|
||||
|
||||
When we run `widget --verbose push --force`, the `PushAction.onExecute()` method will get invoked and then your business logic takes over.
|
||||
|
||||
---
|
||||
|
||||
**For a more complete example, take a look at the [ts-command-line-test](https://github.com/microsoft/rushstack/tree/main/build-tests/ts-command-line-test) sample project.**
|
||||
|
||||
---
|
||||
|
||||
#### Testing out the docs
|
||||
|
||||
If you invoke the tool as "`widget --help`", the docs are automatically generated:
|
||||
|
||||
```
|
||||
usage: widget [-h] [-v] <command> ...
|
||||
|
||||
The "widget" tool is a code sample for using the @rushstack/ts-command-line
|
||||
library.
|
||||
|
||||
Positional arguments:
|
||||
<command>
|
||||
push Pushes a widget to the service
|
||||
|
||||
Optional arguments:
|
||||
-h, --help Show this help message and exit.
|
||||
-v, --verbose Show extra logging detail
|
||||
|
||||
For detailed help about a specific command, use: widget <command> -h
|
||||
```
|
||||
|
||||
For help about the `push` action, the user can type "`widget push --help`", which shows this output:
|
||||
|
||||
```
|
||||
usage: widget push [-h] [-f] [--protocol {ftp,webdav,scp}]
|
||||
|
||||
Here we provide a longer description of how our action works.
|
||||
|
||||
Optional arguments:
|
||||
-h, --help Show this help message and exit.
|
||||
-f, --force Push and overwrite any existing state
|
||||
--protocol {ftp,webdav,scp}
|
||||
Specify the protocol to use. This parameter may
|
||||
alternatively specified via the WIDGET_PROTOCOL
|
||||
environment variable. The default value is "scp".
|
||||
```
|
||||
|
||||
## Dynamic Model
|
||||
|
||||
The action subclasses provide a simple, recognizable pattern that you can use across all your tooling projects. It's the generally recommended approach. However, there are some cases where we need to break out of the scaffold. For example:
|
||||
|
||||
- Actions or parameters may be discovered at runtime, e.g. from a config file
|
||||
- The actions and their implementations may sometimes have very different structures
|
||||
|
||||
In this case, you can use the `DynamicCommandLineAction` and `DynamicCommandLineParser` classes which are not abstract (and not intended to be subclassed). Here's our above example rewritten for this model:
|
||||
|
||||
```typescript
|
||||
// Define the parser
|
||||
const commandLineParser: DynamicCommandLineParser = new DynamicCommandLineParser({
|
||||
toolFilename: 'widget',
|
||||
toolDescription: 'The "widget" tool is a code sample for using the @rushstack/ts-command-line library.'
|
||||
});
|
||||
|
||||
commandLineParser.defineFlagParameter({
|
||||
parameterLongName: '--verbose',
|
||||
parameterShortName: '-v',
|
||||
description: 'Show extra logging detail'
|
||||
});
|
||||
|
||||
// Define the action
|
||||
const action: DynamicCommandLineAction = new DynamicCommandLineAction({
|
||||
actionName: 'push',
|
||||
summary: 'Pushes a widget to the service',
|
||||
documentation: 'Here we provide a longer description of how our action works.'
|
||||
});
|
||||
|
||||
commandLineParser.addAction(action);
|
||||
|
||||
action.defineFlagParameter({
|
||||
parameterLongName: '--force',
|
||||
parameterShortName: '-f',
|
||||
description: 'Push and overwrite any existing state'
|
||||
});
|
||||
|
||||
action.defineChoiceParameter({
|
||||
parameterLongName: '--protocol',
|
||||
description: 'Specify the protocol to use',
|
||||
alternatives: ['ftp', 'webdav', 'scp'],
|
||||
environmentVariable: 'WIDGET_PROTOCOL',
|
||||
defaultValue: 'scp'
|
||||
});
|
||||
|
||||
// Parse the command line
|
||||
commandLineParser.execute().then(() => {
|
||||
console.log('The action is: ' + commandLineParser.selectedAction!.actionName);
|
||||
console.log('The force flag is: ' + action.getFlagParameter('--force').value);
|
||||
});
|
||||
```
|
||||
|
||||
You can also mix the two models. For example, we could augment the `WidgetCommandLine` from the original model by adding `DynamicAction` objects to it.
|
||||
|
||||
|
||||
## Links
|
||||
|
||||
- [CHANGELOG.md](
|
||||
https://github.com/microsoft/rushstack/blob/main/libraries/ts-command-line/CHANGELOG.md) - Find
|
||||
out what's new in the latest version
|
||||
- [API Reference](https://rushstack.io/pages/api/ts-command-line/)
|
||||
|
||||
Here are some real world GitHub projects that illustrate different use cases for **ts-command-line**:
|
||||
|
||||
- [@microsoft/rush](https://www.npmjs.com/package/@microsoft/rush)
|
||||
- [@microsoft/api-extractor](https://www.npmjs.com/package/@microsoft/api-extractor)
|
||||
- [@microsoft/api-documenter](https://www.npmjs.com/package/@microsoft/api-documenter)
|
||||
|
||||
`@rushstack/ts-command-line` is part of the [Rush Stack](https://rushstack.io/) family of projects.
|
1062
node_modules/@rushstack/ts-command-line/dist/ts-command-line.d.ts
generated
vendored
Normal file
1062
node_modules/@rushstack/ts-command-line/dist/ts-command-line.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
11
node_modules/@rushstack/ts-command-line/dist/tsdoc-metadata.json
generated
vendored
Normal file
11
node_modules/@rushstack/ts-command-line/dist/tsdoc-metadata.json
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
||||
// It should be published with your NPM package. It should not be tracked by Git.
|
||||
{
|
||||
"tsdocVersion": "0.12",
|
||||
"toolPackages": [
|
||||
{
|
||||
"packageName": "@microsoft/api-extractor",
|
||||
"packageVersion": "7.37.1"
|
||||
}
|
||||
]
|
||||
}
|
14
node_modules/@rushstack/ts-command-line/lib/CommandLineHelper.d.ts
generated
vendored
Normal file
14
node_modules/@rushstack/ts-command-line/lib/CommandLineHelper.d.ts
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Helpers for working with the ts-command-line API.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare class CommandLineHelper {
|
||||
/**
|
||||
* Returns true if the current command line action is tab-complete.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
static isTabCompletionActionRequest(argv: string[]): boolean;
|
||||
}
|
||||
//# sourceMappingURL=CommandLineHelper.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/CommandLineHelper.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/CommandLineHelper.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineHelper.d.ts","sourceRoot":"","sources":["../src/CommandLineHelper.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,qBAAa,iBAAiB;IAC5B;;;;OAIG;WACW,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO;CAGpE"}
|
22
node_modules/@rushstack/ts-command-line/lib/CommandLineHelper.js
generated
vendored
Normal file
22
node_modules/@rushstack/ts-command-line/lib/CommandLineHelper.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CommandLineHelper = void 0;
|
||||
/**
|
||||
* Helpers for working with the ts-command-line API.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
class CommandLineHelper {
|
||||
/**
|
||||
* Returns true if the current command line action is tab-complete.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
static isTabCompletionActionRequest(argv) {
|
||||
return argv && argv.length > 2 && argv[2] === "tab-complete" /* CommandLineConstants.TabCompletionActionName */;
|
||||
}
|
||||
}
|
||||
exports.CommandLineHelper = CommandLineHelper;
|
||||
//# sourceMappingURL=CommandLineHelper.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/CommandLineHelper.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/CommandLineHelper.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineHelper.js","sourceRoot":"","sources":["../src/CommandLineHelper.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D;;;;GAIG;AACH,MAAa,iBAAiB;IAC5B;;;;OAIG;IACI,MAAM,CAAC,4BAA4B,CAAC,IAAc;QACvD,OAAO,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,sEAAiD,CAAC;IAC7F,CAAC;CACF;AATD,8CASC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { CommandLineConstants } from './Constants';\n\n/**\n * Helpers for working with the ts-command-line API.\n *\n * @public\n */\nexport class CommandLineHelper {\n /**\n * Returns true if the current command line action is tab-complete.\n *\n * @public\n */\n public static isTabCompletionActionRequest(argv: string[]): boolean {\n return argv && argv.length > 2 && argv[2] === CommandLineConstants.TabCompletionActionName;\n }\n}\n"]}
|
13
node_modules/@rushstack/ts-command-line/lib/Constants.d.ts
generated
vendored
Normal file
13
node_modules/@rushstack/ts-command-line/lib/Constants.d.ts
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* String constants for command line processing.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare const enum CommandLineConstants {
|
||||
/**
|
||||
* The name of the built-in action that serves suggestions for tab-completion
|
||||
*/
|
||||
TabCompletionActionName = "tab-complete"
|
||||
}
|
||||
export declare const SCOPING_PARAMETER_GROUP: unique symbol;
|
||||
//# sourceMappingURL=Constants.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/Constants.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/Constants.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Constants.d.ts","sourceRoot":"","sources":["../src/Constants.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,0BAAkB,oBAAoB;IACpC;;OAEG;IACH,uBAAuB,iBAAiB;CACzC;AAED,eAAO,MAAM,uBAAuB,EAAE,OAAO,MAA0B,CAAC"}
|
7
node_modules/@rushstack/ts-command-line/lib/Constants.js
generated
vendored
Normal file
7
node_modules/@rushstack/ts-command-line/lib/Constants.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SCOPING_PARAMETER_GROUP = void 0;
|
||||
exports.SCOPING_PARAMETER_GROUP = Symbol('scoping');
|
||||
//# sourceMappingURL=Constants.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/Constants.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/Constants.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../src/Constants.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAc9C,QAAA,uBAAuB,GAAkB,MAAM,CAAC,SAAS,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * String constants for command line processing.\n *\n * @public\n */\nexport const enum CommandLineConstants {\n /**\n * The name of the built-in action that serves suggestions for tab-completion\n */\n TabCompletionActionName = 'tab-complete'\n}\n\nexport const SCOPING_PARAMETER_GROUP: unique symbol = Symbol('scoping');\n"]}
|
25
node_modules/@rushstack/ts-command-line/lib/index.d.ts
generated
vendored
Normal file
25
node_modules/@rushstack/ts-command-line/lib/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* An object-oriented command-line parser for TypeScript projects.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
export { CommandLineAction, type ICommandLineActionOptions } from './providers/CommandLineAction';
|
||||
export { DynamicCommandLineAction } from './providers/DynamicCommandLineAction';
|
||||
export { ScopedCommandLineAction } from './providers/ScopedCommandLineAction';
|
||||
export { AliasCommandLineAction, type IAliasCommandLineActionOptions } from './providers/AliasCommandLineAction';
|
||||
export type { IBaseCommandLineDefinition, IBaseCommandLineDefinitionWithArgument, ICommandLineFlagDefinition, ICommandLineStringDefinition, ICommandLineStringListDefinition, ICommandLineIntegerDefinition, ICommandLineIntegerListDefinition, ICommandLineChoiceDefinition, ICommandLineChoiceListDefinition, ICommandLineRemainderDefinition } from './parameters/CommandLineDefinition';
|
||||
export { CommandLineParameterKind, CommandLineParameter, CommandLineParameterWithArgument } from './parameters/BaseClasses';
|
||||
export { CommandLineFlagParameter } from './parameters/CommandLineFlagParameter';
|
||||
export { CommandLineStringParameter } from './parameters/CommandLineStringParameter';
|
||||
export { CommandLineStringListParameter } from './parameters/CommandLineStringListParameter';
|
||||
export { CommandLineIntegerParameter } from './parameters/CommandLineIntegerParameter';
|
||||
export { CommandLineIntegerListParameter } from './parameters/CommandLineIntegerListParameter';
|
||||
export { CommandLineChoiceParameter } from './parameters/CommandLineChoiceParameter';
|
||||
export { CommandLineChoiceListParameter } from './parameters/CommandLineChoiceListParameter';
|
||||
export { CommandLineRemainder } from './parameters/CommandLineRemainder';
|
||||
export { CommandLineParameterProvider, type IScopedLongNameParseResult, type ICommandLineParserData as _ICommandLineParserData, type IRegisterDefinedParametersState as _IRegisterDefinedParametersState } from './providers/CommandLineParameterProvider';
|
||||
export { CommandLineParser, type ICommandLineParserOptions } from './providers/CommandLineParser';
|
||||
export { DynamicCommandLineParser } from './providers/DynamicCommandLineParser';
|
||||
export { CommandLineConstants } from './Constants';
|
||||
export { CommandLineHelper } from './CommandLineHelper';
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/index.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,KAAK,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EACL,sBAAsB,EACtB,KAAK,8BAA8B,EACpC,MAAM,oCAAoC,CAAC;AAE5C,YAAY,EACV,0BAA0B,EAC1B,sCAAsC,EACtC,0BAA0B,EAC1B,4BAA4B,EAC5B,gCAAgC,EAChC,6BAA6B,EAC7B,iCAAiC,EACjC,4BAA4B,EAC5B,gCAAgC,EAChC,+BAA+B,EAChC,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,gCAAgC,EACjC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,+BAA+B,EAAE,MAAM,8CAA8C,CAAC;AAC/F,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE,OAAO,EACL,4BAA4B,EAC5B,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,IAAI,uBAAuB,EACtD,KAAK,+BAA+B,IAAI,gCAAgC,EACzE,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,KAAK,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
47
node_modules/@rushstack/ts-command-line/lib/index.js
generated
vendored
Normal file
47
node_modules/@rushstack/ts-command-line/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CommandLineHelper = exports.DynamicCommandLineParser = exports.CommandLineParser = exports.CommandLineParameterProvider = exports.CommandLineRemainder = exports.CommandLineChoiceListParameter = exports.CommandLineChoiceParameter = exports.CommandLineIntegerListParameter = exports.CommandLineIntegerParameter = exports.CommandLineStringListParameter = exports.CommandLineStringParameter = exports.CommandLineFlagParameter = exports.CommandLineParameterWithArgument = exports.CommandLineParameter = exports.CommandLineParameterKind = exports.AliasCommandLineAction = exports.ScopedCommandLineAction = exports.DynamicCommandLineAction = exports.CommandLineAction = void 0;
|
||||
/**
|
||||
* An object-oriented command-line parser for TypeScript projects.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
var CommandLineAction_1 = require("./providers/CommandLineAction");
|
||||
Object.defineProperty(exports, "CommandLineAction", { enumerable: true, get: function () { return CommandLineAction_1.CommandLineAction; } });
|
||||
var DynamicCommandLineAction_1 = require("./providers/DynamicCommandLineAction");
|
||||
Object.defineProperty(exports, "DynamicCommandLineAction", { enumerable: true, get: function () { return DynamicCommandLineAction_1.DynamicCommandLineAction; } });
|
||||
var ScopedCommandLineAction_1 = require("./providers/ScopedCommandLineAction");
|
||||
Object.defineProperty(exports, "ScopedCommandLineAction", { enumerable: true, get: function () { return ScopedCommandLineAction_1.ScopedCommandLineAction; } });
|
||||
var AliasCommandLineAction_1 = require("./providers/AliasCommandLineAction");
|
||||
Object.defineProperty(exports, "AliasCommandLineAction", { enumerable: true, get: function () { return AliasCommandLineAction_1.AliasCommandLineAction; } });
|
||||
var BaseClasses_1 = require("./parameters/BaseClasses");
|
||||
Object.defineProperty(exports, "CommandLineParameterKind", { enumerable: true, get: function () { return BaseClasses_1.CommandLineParameterKind; } });
|
||||
Object.defineProperty(exports, "CommandLineParameter", { enumerable: true, get: function () { return BaseClasses_1.CommandLineParameter; } });
|
||||
Object.defineProperty(exports, "CommandLineParameterWithArgument", { enumerable: true, get: function () { return BaseClasses_1.CommandLineParameterWithArgument; } });
|
||||
var CommandLineFlagParameter_1 = require("./parameters/CommandLineFlagParameter");
|
||||
Object.defineProperty(exports, "CommandLineFlagParameter", { enumerable: true, get: function () { return CommandLineFlagParameter_1.CommandLineFlagParameter; } });
|
||||
var CommandLineStringParameter_1 = require("./parameters/CommandLineStringParameter");
|
||||
Object.defineProperty(exports, "CommandLineStringParameter", { enumerable: true, get: function () { return CommandLineStringParameter_1.CommandLineStringParameter; } });
|
||||
var CommandLineStringListParameter_1 = require("./parameters/CommandLineStringListParameter");
|
||||
Object.defineProperty(exports, "CommandLineStringListParameter", { enumerable: true, get: function () { return CommandLineStringListParameter_1.CommandLineStringListParameter; } });
|
||||
var CommandLineIntegerParameter_1 = require("./parameters/CommandLineIntegerParameter");
|
||||
Object.defineProperty(exports, "CommandLineIntegerParameter", { enumerable: true, get: function () { return CommandLineIntegerParameter_1.CommandLineIntegerParameter; } });
|
||||
var CommandLineIntegerListParameter_1 = require("./parameters/CommandLineIntegerListParameter");
|
||||
Object.defineProperty(exports, "CommandLineIntegerListParameter", { enumerable: true, get: function () { return CommandLineIntegerListParameter_1.CommandLineIntegerListParameter; } });
|
||||
var CommandLineChoiceParameter_1 = require("./parameters/CommandLineChoiceParameter");
|
||||
Object.defineProperty(exports, "CommandLineChoiceParameter", { enumerable: true, get: function () { return CommandLineChoiceParameter_1.CommandLineChoiceParameter; } });
|
||||
var CommandLineChoiceListParameter_1 = require("./parameters/CommandLineChoiceListParameter");
|
||||
Object.defineProperty(exports, "CommandLineChoiceListParameter", { enumerable: true, get: function () { return CommandLineChoiceListParameter_1.CommandLineChoiceListParameter; } });
|
||||
var CommandLineRemainder_1 = require("./parameters/CommandLineRemainder");
|
||||
Object.defineProperty(exports, "CommandLineRemainder", { enumerable: true, get: function () { return CommandLineRemainder_1.CommandLineRemainder; } });
|
||||
var CommandLineParameterProvider_1 = require("./providers/CommandLineParameterProvider");
|
||||
Object.defineProperty(exports, "CommandLineParameterProvider", { enumerable: true, get: function () { return CommandLineParameterProvider_1.CommandLineParameterProvider; } });
|
||||
var CommandLineParser_1 = require("./providers/CommandLineParser");
|
||||
Object.defineProperty(exports, "CommandLineParser", { enumerable: true, get: function () { return CommandLineParser_1.CommandLineParser; } });
|
||||
var DynamicCommandLineParser_1 = require("./providers/DynamicCommandLineParser");
|
||||
Object.defineProperty(exports, "DynamicCommandLineParser", { enumerable: true, get: function () { return DynamicCommandLineParser_1.DynamicCommandLineParser; } });
|
||||
var CommandLineHelper_1 = require("./CommandLineHelper");
|
||||
Object.defineProperty(exports, "CommandLineHelper", { enumerable: true, get: function () { return CommandLineHelper_1.CommandLineHelper; } });
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/index.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;;GAIG;AAEH,mEAAkG;AAAzF,sHAAA,iBAAiB,OAAA;AAC1B,iFAAgF;AAAvE,oIAAA,wBAAwB,OAAA;AACjC,+EAA8E;AAArE,kIAAA,uBAAuB,OAAA;AAChC,6EAG4C;AAF1C,gIAAA,sBAAsB,OAAA;AAiBxB,wDAIkC;AAHhC,uHAAA,wBAAwB,OAAA;AACxB,mHAAA,oBAAoB,OAAA;AACpB,+HAAA,gCAAgC,OAAA;AAGlC,kFAAiF;AAAxE,oIAAA,wBAAwB,OAAA;AACjC,sFAAqF;AAA5E,wIAAA,0BAA0B,OAAA;AACnC,8FAA6F;AAApF,gJAAA,8BAA8B,OAAA;AACvC,wFAAuF;AAA9E,0IAAA,2BAA2B,OAAA;AACpC,gGAA+F;AAAtF,kJAAA,+BAA+B,OAAA;AACxC,sFAAqF;AAA5E,wIAAA,0BAA0B,OAAA;AACnC,8FAA6F;AAApF,gJAAA,8BAA8B,OAAA;AACvC,0EAAyE;AAAhE,4HAAA,oBAAoB,OAAA;AAE7B,yFAKkD;AAJhD,4IAAA,4BAA4B,OAAA;AAM9B,mEAAkG;AAAzF,sHAAA,iBAAiB,OAAA;AAC1B,iFAAgF;AAAvE,oIAAA,wBAAwB,OAAA;AAIjC,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * An object-oriented command-line parser for TypeScript projects.\n *\n * @packageDocumentation\n */\n\nexport { CommandLineAction, type ICommandLineActionOptions } from './providers/CommandLineAction';\nexport { DynamicCommandLineAction } from './providers/DynamicCommandLineAction';\nexport { ScopedCommandLineAction } from './providers/ScopedCommandLineAction';\nexport {\n AliasCommandLineAction,\n type IAliasCommandLineActionOptions\n} from './providers/AliasCommandLineAction';\n\nexport type {\n IBaseCommandLineDefinition,\n IBaseCommandLineDefinitionWithArgument,\n ICommandLineFlagDefinition,\n ICommandLineStringDefinition,\n ICommandLineStringListDefinition,\n ICommandLineIntegerDefinition,\n ICommandLineIntegerListDefinition,\n ICommandLineChoiceDefinition,\n ICommandLineChoiceListDefinition,\n ICommandLineRemainderDefinition\n} from './parameters/CommandLineDefinition';\n\nexport {\n CommandLineParameterKind,\n CommandLineParameter,\n CommandLineParameterWithArgument\n} from './parameters/BaseClasses';\n\nexport { CommandLineFlagParameter } from './parameters/CommandLineFlagParameter';\nexport { CommandLineStringParameter } from './parameters/CommandLineStringParameter';\nexport { CommandLineStringListParameter } from './parameters/CommandLineStringListParameter';\nexport { CommandLineIntegerParameter } from './parameters/CommandLineIntegerParameter';\nexport { CommandLineIntegerListParameter } from './parameters/CommandLineIntegerListParameter';\nexport { CommandLineChoiceParameter } from './parameters/CommandLineChoiceParameter';\nexport { CommandLineChoiceListParameter } from './parameters/CommandLineChoiceListParameter';\nexport { CommandLineRemainder } from './parameters/CommandLineRemainder';\n\nexport {\n CommandLineParameterProvider,\n type IScopedLongNameParseResult,\n type ICommandLineParserData as _ICommandLineParserData,\n type IRegisterDefinedParametersState as _IRegisterDefinedParametersState\n} from './providers/CommandLineParameterProvider';\n\nexport { CommandLineParser, type ICommandLineParserOptions } from './providers/CommandLineParser';\nexport { DynamicCommandLineParser } from './providers/DynamicCommandLineParser';\n\nexport { CommandLineConstants } from './Constants';\n\nexport { CommandLineHelper } from './CommandLineHelper';\n"]}
|
108
node_modules/@rushstack/ts-command-line/lib/parameters/BaseClasses.d.ts
generated
vendored
Normal file
108
node_modules/@rushstack/ts-command-line/lib/parameters/BaseClasses.d.ts
generated
vendored
Normal file
@ -0,0 +1,108 @@
|
||||
import type { SCOPING_PARAMETER_GROUP } from '../Constants';
|
||||
import type { IBaseCommandLineDefinition, IBaseCommandLineDefinitionWithArgument } from './CommandLineDefinition';
|
||||
/**
|
||||
* Identifies the kind of a CommandLineParameter.
|
||||
* @public
|
||||
*/
|
||||
export declare enum CommandLineParameterKind {
|
||||
/** Indicates a CommandLineChoiceParameter */
|
||||
Choice = 0,
|
||||
/** Indicates a CommandLineFlagParameter */
|
||||
Flag = 1,
|
||||
/** Indicates a CommandLineIntegerParameter */
|
||||
Integer = 2,
|
||||
/** Indicates a CommandLineStringParameter */
|
||||
String = 3,
|
||||
/** Indicates a CommandLineStringListParameter */
|
||||
StringList = 4,
|
||||
/** Indicates a CommandLineChoiceListParameter */
|
||||
ChoiceList = 5,
|
||||
/** Indicates a CommandLineIntegerListParameter */
|
||||
IntegerList = 6
|
||||
}
|
||||
/**
|
||||
* The base class for the various command-line parameter types.
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class CommandLineParameter {
|
||||
private _shortNameValue;
|
||||
/**
|
||||
* A unique internal key used to retrieve the value from the parser's dictionary.
|
||||
* @internal
|
||||
*/
|
||||
_parserKey: string | undefined;
|
||||
/** {@inheritDoc IBaseCommandLineDefinition.parameterLongName} */
|
||||
readonly longName: string;
|
||||
/**
|
||||
* If a parameterScope is provided, returns the scope-prefixed long name of the flag,
|
||||
* including double dashes, eg. "--scope:do-something". Otherwise undefined.
|
||||
*/
|
||||
readonly scopedLongName: string | undefined;
|
||||
/** {@inheritDoc IBaseCommandLineDefinition.parameterGroup} */
|
||||
readonly parameterGroup: string | typeof SCOPING_PARAMETER_GROUP | undefined;
|
||||
/** {@inheritDoc IBaseCommandLineDefinition.parameterScope} */
|
||||
readonly parameterScope: string | undefined;
|
||||
/** {@inheritDoc IBaseCommandLineDefinition.description} */
|
||||
readonly description: string;
|
||||
/** {@inheritDoc IBaseCommandLineDefinition.required} */
|
||||
readonly required: boolean;
|
||||
/** {@inheritDoc IBaseCommandLineDefinition.environmentVariable} */
|
||||
readonly environmentVariable: string | undefined;
|
||||
/** {@inheritDoc IBaseCommandLineDefinition.undocumentedSynonyms } */
|
||||
readonly undocumentedSynonyms: string[] | undefined;
|
||||
/** @internal */
|
||||
constructor(definition: IBaseCommandLineDefinition);
|
||||
/** {@inheritDoc IBaseCommandLineDefinition.parameterShortName} */
|
||||
get shortName(): string | undefined;
|
||||
/**
|
||||
* Called internally by CommandLineParameterProvider._processParsedData()
|
||||
* @internal
|
||||
*/
|
||||
abstract _setValue(data: any): void;
|
||||
/**
|
||||
* Returns additional text used by the help formatter.
|
||||
* @internal
|
||||
*/
|
||||
_getSupplementaryNotes(supplementaryNotes: string[]): void;
|
||||
/**
|
||||
* Indicates the type of parameter.
|
||||
*/
|
||||
abstract get kind(): CommandLineParameterKind;
|
||||
/**
|
||||
* Append the parsed values to the provided string array.
|
||||
* @remarks
|
||||
* Sometimes a command line parameter is not used directly, but instead gets passed through to another
|
||||
* tool that will use it. For example if our parameter comes in as "--max-count 3", then we might want to
|
||||
* call `child_process.spawn()` and append ["--max-count", "3"] to the args array for that tool.
|
||||
* appendToArgList() appends zero or more strings to the provided array, based on the input command-line
|
||||
* that we parsed.
|
||||
*
|
||||
* If the parameter was omitted from our command-line and has no default value, then
|
||||
* nothing will be appended. If the short name was used, the long name will be appended instead.
|
||||
* @param argList - the parsed strings will be appended to this string array
|
||||
*/
|
||||
abstract appendToArgList(argList: string[]): void;
|
||||
/**
|
||||
* Internal usage only. Used to report unexpected output from the argparse library.
|
||||
*/
|
||||
protected reportInvalidData(data: any): never;
|
||||
protected validateDefaultValue(hasDefaultValue: boolean): void;
|
||||
}
|
||||
/**
|
||||
* The common base class for parameters types that receive an argument.
|
||||
*
|
||||
* @remarks
|
||||
* An argument is an accompanying command-line token, such as "123" in the
|
||||
* example "--max-count 123".
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class CommandLineParameterWithArgument extends CommandLineParameter {
|
||||
private static _invalidArgumentNameRegExp;
|
||||
/** {@inheritDoc IBaseCommandLineDefinitionWithArgument.argumentName} */
|
||||
readonly argumentName: string;
|
||||
/** {@inheritDoc IBaseCommandLineDefinitionWithArgument.completions} */
|
||||
readonly completions: (() => Promise<string[]>) | undefined;
|
||||
/** @internal */
|
||||
constructor(definition: IBaseCommandLineDefinitionWithArgument);
|
||||
}
|
||||
//# sourceMappingURL=BaseClasses.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/BaseClasses.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/BaseClasses.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"BaseClasses.d.ts","sourceRoot":"","sources":["../../src/parameters/BaseClasses.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EACV,0BAA0B,EAC1B,sCAAsC,EACvC,MAAM,yBAAyB,CAAC;AAEjC;;;GAGG;AACH,oBAAY,wBAAwB;IAClC,6CAA6C;IAC7C,MAAM,IAAA;IACN,2CAA2C;IAC3C,IAAI,IAAA;IACJ,8CAA8C;IAC9C,OAAO,IAAA;IACP,6CAA6C;IAC7C,MAAM,IAAA;IACN,iDAAiD;IACjD,UAAU,IAAA;IACV,iDAAiD;IACjD,UAAU,IAAA;IACV,kDAAkD;IAClD,WAAW,IAAA;CACZ;AA4BD;;;GAGG;AACH,8BAAsB,oBAAoB;IACxC,OAAO,CAAC,eAAe,CAAqB;IAE5C;;;OAGG;IACI,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAEtC,iEAAiE;IACjE,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAEjC;;;OAGG;IACH,SAAgB,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnD,8DAA8D;IAC9D,SAAgB,cAAc,EAAE,MAAM,GAAG,OAAO,uBAAuB,GAAG,SAAS,CAAC;IAEpF,8DAA8D;IAC9D,SAAgB,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnD,2DAA2D;IAC3D,SAAgB,WAAW,EAAE,MAAM,CAAC;IAEpC,wDAAwD;IACxD,SAAgB,QAAQ,EAAE,OAAO,CAAC;IAElC,mEAAmE;IACnE,SAAgB,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IAExD,qEAAqE;IACrE,SAAgB,oBAAoB,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAE3D,gBAAgB;gBACG,UAAU,EAAE,0BAA0B;IAyEzD,kEAAkE;IAClE,IAAW,SAAS,IAAI,MAAM,GAAG,SAAS,CAEzC;IAED;;;OAGG;aACa,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAE1C;;;OAGG;IACI,sBAAsB,CAAC,kBAAkB,EAAE,MAAM,EAAE,GAAG,IAAI;IAWjE;;OAEG;IACH,aAAoB,IAAI,IAAI,wBAAwB,CAAC;IAErD;;;;;;;;;;;;OAYG;aACa,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAExD;;OAEG;IAEH,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,KAAK;IAI7C,SAAS,CAAC,oBAAoB,CAAC,eAAe,EAAE,OAAO,GAAG,IAAI;CAY/D;AAED;;;;;;;GAOG;AACH,8BAAsB,gCAAiC,SAAQ,oBAAoB;IAEjF,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAAwB;IAEjE,wEAAwE;IACxE,SAAgB,YAAY,EAAE,MAAM,CAAC;IAErC,uEAAuE;IACvE,SAAgB,WAAW,EAAE,CAAC,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;IAEnE,gBAAgB;gBACG,UAAU,EAAE,sCAAsC;CAyBtE"}
|
173
node_modules/@rushstack/ts-command-line/lib/parameters/BaseClasses.js
generated
vendored
Normal file
173
node_modules/@rushstack/ts-command-line/lib/parameters/BaseClasses.js
generated
vendored
Normal file
@ -0,0 +1,173 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CommandLineParameterWithArgument = exports.CommandLineParameter = exports.CommandLineParameterKind = void 0;
|
||||
/**
|
||||
* Identifies the kind of a CommandLineParameter.
|
||||
* @public
|
||||
*/
|
||||
var CommandLineParameterKind;
|
||||
(function (CommandLineParameterKind) {
|
||||
/** Indicates a CommandLineChoiceParameter */
|
||||
CommandLineParameterKind[CommandLineParameterKind["Choice"] = 0] = "Choice";
|
||||
/** Indicates a CommandLineFlagParameter */
|
||||
CommandLineParameterKind[CommandLineParameterKind["Flag"] = 1] = "Flag";
|
||||
/** Indicates a CommandLineIntegerParameter */
|
||||
CommandLineParameterKind[CommandLineParameterKind["Integer"] = 2] = "Integer";
|
||||
/** Indicates a CommandLineStringParameter */
|
||||
CommandLineParameterKind[CommandLineParameterKind["String"] = 3] = "String";
|
||||
/** Indicates a CommandLineStringListParameter */
|
||||
CommandLineParameterKind[CommandLineParameterKind["StringList"] = 4] = "StringList";
|
||||
/** Indicates a CommandLineChoiceListParameter */
|
||||
CommandLineParameterKind[CommandLineParameterKind["ChoiceList"] = 5] = "ChoiceList";
|
||||
/** Indicates a CommandLineIntegerListParameter */
|
||||
CommandLineParameterKind[CommandLineParameterKind["IntegerList"] = 6] = "IntegerList";
|
||||
})(CommandLineParameterKind = exports.CommandLineParameterKind || (exports.CommandLineParameterKind = {}));
|
||||
/**
|
||||
* Matches kebab-case formatted strings prefixed with double dashes.
|
||||
* Example: "--do-something"
|
||||
*/
|
||||
const LONG_NAME_REGEXP = /^-(-[a-z0-9]+)+$/;
|
||||
/**
|
||||
* Matches a single upper-case or lower-case letter prefixed with a dash.
|
||||
* Example: "-d"
|
||||
*/
|
||||
const SHORT_NAME_REGEXP = /^-[a-zA-Z]$/;
|
||||
/**
|
||||
* Matches kebab-case formatted strings
|
||||
* Example: "my-scope"
|
||||
*/
|
||||
const SCOPE_REGEXP = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
||||
/**
|
||||
* "Environment variable names used by the utilities in the Shell and Utilities volume of
|
||||
* IEEE Std 1003.1-2001 consist solely of uppercase letters, digits, and the '_' (underscore)
|
||||
* from the characters defined in Portable Character Set and do not begin with a digit."
|
||||
* Example: "THE_SETTING"
|
||||
*/
|
||||
const ENVIRONMENT_VARIABLE_NAME_REGEXP = /^[A-Z_][A-Z0-9_]*$/;
|
||||
/**
|
||||
* The base class for the various command-line parameter types.
|
||||
* @public
|
||||
*/
|
||||
class CommandLineParameter {
|
||||
/** @internal */
|
||||
constructor(definition) {
|
||||
this.longName = definition.parameterLongName;
|
||||
this._shortNameValue = definition.parameterShortName;
|
||||
this.parameterGroup = definition.parameterGroup;
|
||||
this.parameterScope = definition.parameterScope;
|
||||
this.description = definition.description;
|
||||
this.required = !!definition.required;
|
||||
this.environmentVariable = definition.environmentVariable;
|
||||
this.undocumentedSynonyms = definition.undocumentedSynonyms;
|
||||
if (!LONG_NAME_REGEXP.test(this.longName)) {
|
||||
throw new Error(`Invalid name: "${this.longName}". The parameter long name must be` +
|
||||
` lower-case and use dash delimiters (e.g. "--do-a-thing")`);
|
||||
}
|
||||
if (this.shortName) {
|
||||
if (!SHORT_NAME_REGEXP.test(this.shortName)) {
|
||||
throw new Error(`Invalid name: "${this.shortName}". The parameter short name must be` +
|
||||
` a dash followed by a single upper-case or lower-case letter (e.g. "-a")`);
|
||||
}
|
||||
}
|
||||
if (this.parameterScope) {
|
||||
if (!SCOPE_REGEXP.test(this.parameterScope)) {
|
||||
throw new Error(`Invalid scope: "${this.parameterScope}". The parameter scope name must be` +
|
||||
` lower-case and use dash delimiters (e.g. "my-scope")`);
|
||||
}
|
||||
// Parameter long name is guaranteed to start with '--' since this is validated above
|
||||
const unprefixedLongName = this.longName.slice(2);
|
||||
this.scopedLongName = `--${this.parameterScope}:${unprefixedLongName}`;
|
||||
}
|
||||
if (this.environmentVariable) {
|
||||
if (this.required) {
|
||||
// TODO: This constraint is imposed only because argparse enforces "required" parameters, but
|
||||
// it does not know about ts-command-line environment variable mappings. We should fix this.
|
||||
throw new Error(`An "environmentVariable" cannot be specified for "${this.longName}"` +
|
||||
` because it is a required parameter`);
|
||||
}
|
||||
if (!ENVIRONMENT_VARIABLE_NAME_REGEXP.test(this.environmentVariable)) {
|
||||
throw new Error(`Invalid environment variable name: "${this.environmentVariable}". The name must` +
|
||||
` consist only of upper-case letters, numbers, and underscores. It may not start with a number.`);
|
||||
}
|
||||
}
|
||||
if (this.undocumentedSynonyms && this.undocumentedSynonyms.length > 0) {
|
||||
for (const undocumentedSynonym of this.undocumentedSynonyms) {
|
||||
if (this.longName === undocumentedSynonym) {
|
||||
throw new Error(`Invalid name: "${undocumentedSynonym}". Undocumented synonyms must not be the same` +
|
||||
` as the the long name.`);
|
||||
}
|
||||
else if (!LONG_NAME_REGEXP.test(undocumentedSynonym)) {
|
||||
throw new Error(`Invalid name: "${undocumentedSynonym}". All undocumented synonyms name must be lower-case and ` +
|
||||
'use dash delimiters (e.g. "--do-a-thing")');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/** {@inheritDoc IBaseCommandLineDefinition.parameterShortName} */
|
||||
get shortName() {
|
||||
return this._shortNameValue;
|
||||
}
|
||||
/**
|
||||
* Returns additional text used by the help formatter.
|
||||
* @internal
|
||||
*/
|
||||
_getSupplementaryNotes(supplementaryNotes) {
|
||||
// virtual
|
||||
if (this.environmentVariable !== undefined) {
|
||||
supplementaryNotes.push('This parameter may alternatively be specified via the ' +
|
||||
this.environmentVariable +
|
||||
' environment variable.');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Internal usage only. Used to report unexpected output from the argparse library.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
reportInvalidData(data) {
|
||||
throw new Error(`Unexpected data object for parameter "${this.longName}": ` + JSON.stringify(data));
|
||||
}
|
||||
validateDefaultValue(hasDefaultValue) {
|
||||
if (this.required && hasDefaultValue) {
|
||||
// If a parameter is "required", then the user understands that they always need to
|
||||
// specify a value for this parameter (either via the command line or via an environment variable).
|
||||
// It would be confusing to allow a default value that sometimes allows the "required" parameter
|
||||
// to be omitted. If you sometimes don't have a suitable default value, then the better approach
|
||||
// is to throw a custom error explaining why the parameter is required in that case.
|
||||
throw new Error(`A default value cannot be specified for "${this.longName}" because it is a "required" parameter`);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.CommandLineParameter = CommandLineParameter;
|
||||
/**
|
||||
* The common base class for parameters types that receive an argument.
|
||||
*
|
||||
* @remarks
|
||||
* An argument is an accompanying command-line token, such as "123" in the
|
||||
* example "--max-count 123".
|
||||
* @public
|
||||
*/
|
||||
class CommandLineParameterWithArgument extends CommandLineParameter {
|
||||
/** @internal */
|
||||
constructor(definition) {
|
||||
super(definition);
|
||||
if (definition.argumentName === '') {
|
||||
throw new Error('The argument name cannot be an empty string. (For the default name, specify undefined.)');
|
||||
}
|
||||
if (definition.argumentName.toUpperCase() !== definition.argumentName) {
|
||||
throw new Error(`Invalid name: "${definition.argumentName}". The argument name must be all upper case.`);
|
||||
}
|
||||
const match = definition.argumentName.match(CommandLineParameterWithArgument._invalidArgumentNameRegExp);
|
||||
if (match) {
|
||||
throw new Error(`The argument name "${definition.argumentName}" contains an invalid character "${match[0]}".` +
|
||||
` Only upper-case letters, numbers, and underscores are allowed.`);
|
||||
}
|
||||
this.argumentName = definition.argumentName;
|
||||
this.completions = definition.completions;
|
||||
}
|
||||
}
|
||||
// Matches the first character that *isn't* part of a valid upper-case argument name such as "URL_2"
|
||||
CommandLineParameterWithArgument._invalidArgumentNameRegExp = /[^A-Z_0-9]/;
|
||||
exports.CommandLineParameterWithArgument = CommandLineParameterWithArgument;
|
||||
//# sourceMappingURL=BaseClasses.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/BaseClasses.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/BaseClasses.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
33
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineChoiceListParameter.d.ts
generated
vendored
Normal file
33
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineChoiceListParameter.d.ts
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
import type { ICommandLineChoiceListDefinition } from './CommandLineDefinition';
|
||||
import { CommandLineParameter, CommandLineParameterKind } from './BaseClasses';
|
||||
/**
|
||||
* The data type returned by {@link CommandLineParameterProvider.defineChoiceListParameter}.
|
||||
* @public
|
||||
*/
|
||||
export declare class CommandLineChoiceListParameter extends CommandLineParameter {
|
||||
/** {@inheritDoc ICommandLineChoiceListDefinition.alternatives} */
|
||||
readonly alternatives: ReadonlyArray<string>;
|
||||
private _values;
|
||||
/** {@inheritDoc ICommandLineChoiceListDefinition.completions} */
|
||||
readonly completions: (() => Promise<string[]>) | undefined;
|
||||
/** @internal */
|
||||
constructor(definition: ICommandLineChoiceListDefinition);
|
||||
/** {@inheritDoc CommandLineParameter.kind} */
|
||||
get kind(): CommandLineParameterKind;
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._setValue}
|
||||
* @internal
|
||||
*/
|
||||
_setValue(data: any): void;
|
||||
/**
|
||||
* Returns the string arguments for a choice list parameter that was parsed from the command line.
|
||||
*
|
||||
* @remarks
|
||||
* The array will be empty if the command-line has not been parsed yet,
|
||||
* or if the parameter was omitted and has no default value.
|
||||
*/
|
||||
get values(): ReadonlyArray<string>;
|
||||
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
||||
appendToArgList(argList: string[]): void;
|
||||
}
|
||||
//# sourceMappingURL=CommandLineChoiceListParameter.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineChoiceListParameter.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineChoiceListParameter.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineChoiceListParameter.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceListParameter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAG/E;;;GAGG;AACH,qBAAa,8BAA+B,SAAQ,oBAAoB;IACtE,kEAAkE;IAClE,SAAgB,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAEpD,OAAO,CAAC,OAAO,CAAgB;IAE/B,iEAAiE;IACjE,SAAgB,WAAW,EAAE,CAAC,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;IAEnE,gBAAgB;gBACG,UAAU,EAAE,gCAAgC;IAa/D,8CAA8C;IAC9C,IAAW,IAAI,IAAI,wBAAwB,CAE1C;IAED;;;OAGG;IAEI,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAqCjC;;;;;;OAMG;IACH,IAAW,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,CAEzC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;CAQhD"}
|
84
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineChoiceListParameter.js
generated
vendored
Normal file
84
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineChoiceListParameter.js
generated
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CommandLineChoiceListParameter = void 0;
|
||||
const BaseClasses_1 = require("./BaseClasses");
|
||||
const EnvironmentVariableParser_1 = require("./EnvironmentVariableParser");
|
||||
/**
|
||||
* The data type returned by {@link CommandLineParameterProvider.defineChoiceListParameter}.
|
||||
* @public
|
||||
*/
|
||||
class CommandLineChoiceListParameter extends BaseClasses_1.CommandLineParameter {
|
||||
/** @internal */
|
||||
constructor(definition) {
|
||||
super(definition);
|
||||
this._values = [];
|
||||
if (definition.alternatives.length < 1) {
|
||||
throw new Error(`When defining a choice list parameter, the alternatives list must contain at least one value.`);
|
||||
}
|
||||
this.alternatives = definition.alternatives;
|
||||
this.completions = definition.completions;
|
||||
}
|
||||
/** {@inheritDoc CommandLineParameter.kind} */
|
||||
get kind() {
|
||||
return BaseClasses_1.CommandLineParameterKind.ChoiceList;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._setValue}
|
||||
* @internal
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
_setValue(data) {
|
||||
// If argparse passed us a value, confirm it is valid
|
||||
if (data !== null && data !== undefined) {
|
||||
if (!Array.isArray(data)) {
|
||||
this.reportInvalidData(data);
|
||||
}
|
||||
for (const arrayItem of data) {
|
||||
if (typeof arrayItem !== 'string') {
|
||||
this.reportInvalidData(data);
|
||||
}
|
||||
}
|
||||
this._values = data;
|
||||
return;
|
||||
}
|
||||
if (this.environmentVariable !== undefined) {
|
||||
const values = EnvironmentVariableParser_1.EnvironmentVariableParser.parseAsList(this.environmentVariable);
|
||||
if (values) {
|
||||
for (const value of values) {
|
||||
if (this.alternatives.indexOf(value) < 0) {
|
||||
const choices = '"' + this.alternatives.join('", "') + '"';
|
||||
throw new Error(`Invalid value "${value}" for the environment variable` +
|
||||
` ${this.environmentVariable}. Valid choices are: ${choices}`);
|
||||
}
|
||||
}
|
||||
this._values = values;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// (No default value for choice lists)
|
||||
this._values = [];
|
||||
}
|
||||
/**
|
||||
* Returns the string arguments for a choice list parameter that was parsed from the command line.
|
||||
*
|
||||
* @remarks
|
||||
* The array will be empty if the command-line has not been parsed yet,
|
||||
* or if the parameter was omitted and has no default value.
|
||||
*/
|
||||
get values() {
|
||||
return this._values;
|
||||
}
|
||||
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
||||
appendToArgList(argList) {
|
||||
if (this.values.length > 0) {
|
||||
for (const value of this.values) {
|
||||
argList.push(this.longName);
|
||||
argList.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.CommandLineChoiceListParameter = CommandLineChoiceListParameter;
|
||||
//# sourceMappingURL=CommandLineChoiceListParameter.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineChoiceListParameter.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineChoiceListParameter.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
40
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineChoiceParameter.d.ts
generated
vendored
Normal file
40
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineChoiceParameter.d.ts
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
import type { ICommandLineChoiceDefinition } from './CommandLineDefinition';
|
||||
import { CommandLineParameter, CommandLineParameterKind } from './BaseClasses';
|
||||
/**
|
||||
* The data type returned by {@link CommandLineParameterProvider.defineChoiceParameter}.
|
||||
* @public
|
||||
*/
|
||||
export declare class CommandLineChoiceParameter extends CommandLineParameter {
|
||||
/** {@inheritDoc ICommandLineChoiceDefinition.alternatives} */
|
||||
readonly alternatives: ReadonlyArray<string>;
|
||||
/** {@inheritDoc ICommandLineStringDefinition.defaultValue} */
|
||||
readonly defaultValue: string | undefined;
|
||||
private _value;
|
||||
/** {@inheritDoc ICommandLineChoiceDefinition.completions} */
|
||||
readonly completions: (() => Promise<string[]>) | undefined;
|
||||
/** @internal */
|
||||
constructor(definition: ICommandLineChoiceDefinition);
|
||||
/** {@inheritDoc CommandLineParameter.kind} */
|
||||
get kind(): CommandLineParameterKind;
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._setValue}
|
||||
* @internal
|
||||
*/
|
||||
_setValue(data: any): void;
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._getSupplementaryNotes}
|
||||
* @internal
|
||||
*/
|
||||
_getSupplementaryNotes(supplementaryNotes: string[]): void;
|
||||
/**
|
||||
* Returns the argument value for a choice parameter that was parsed from the command line.
|
||||
*
|
||||
* @remarks
|
||||
* The return value will be `undefined` if the command-line has not been parsed yet,
|
||||
* or if the parameter was omitted and has no default value.
|
||||
*/
|
||||
get value(): string | undefined;
|
||||
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
||||
appendToArgList(argList: string[]): void;
|
||||
}
|
||||
//# sourceMappingURL=CommandLineChoiceParameter.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineChoiceParameter.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineChoiceParameter.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineChoiceParameter.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceParameter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAE/E;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,oBAAoB;IAClE,8DAA8D;IAC9D,SAAgB,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAEpD,8DAA8D;IAC9D,SAAgB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjD,OAAO,CAAC,MAAM,CAAiC;IAE/C,6DAA6D;IAC7D,SAAgB,WAAW,EAAE,CAAC,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;IAEnE,gBAAgB;gBACG,UAAU,EAAE,4BAA4B;IAqB3D,8CAA8C;IAC9C,IAAW,IAAI,IAAI,wBAAwB,CAE1C;IAED;;;OAGG;IAEI,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAkCjC;;;OAGG;IACI,sBAAsB,CAAC,kBAAkB,EAAE,MAAM,EAAE,GAAG,IAAI;IAQjE;;;;;;OAMG;IACH,IAAW,KAAK,IAAI,MAAM,GAAG,SAAS,CAErC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;CAMhD"}
|
95
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineChoiceParameter.js
generated
vendored
Normal file
95
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineChoiceParameter.js
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CommandLineChoiceParameter = void 0;
|
||||
const BaseClasses_1 = require("./BaseClasses");
|
||||
/**
|
||||
* The data type returned by {@link CommandLineParameterProvider.defineChoiceParameter}.
|
||||
* @public
|
||||
*/
|
||||
class CommandLineChoiceParameter extends BaseClasses_1.CommandLineParameter {
|
||||
/** @internal */
|
||||
constructor(definition) {
|
||||
super(definition);
|
||||
this._value = undefined;
|
||||
if (definition.alternatives.length < 1) {
|
||||
throw new Error(`When defining a choice parameter, the alternatives list must contain at least one value.`);
|
||||
}
|
||||
if (definition.defaultValue && definition.alternatives.indexOf(definition.defaultValue) === -1) {
|
||||
throw new Error(`The specified default value "${definition.defaultValue}"` +
|
||||
` is not one of the available options: ${definition.alternatives.toString()}`);
|
||||
}
|
||||
this.alternatives = definition.alternatives;
|
||||
this.defaultValue = definition.defaultValue;
|
||||
this.validateDefaultValue(!!this.defaultValue);
|
||||
this.completions = definition.completions;
|
||||
}
|
||||
/** {@inheritDoc CommandLineParameter.kind} */
|
||||
get kind() {
|
||||
return BaseClasses_1.CommandLineParameterKind.Choice;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._setValue}
|
||||
* @internal
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
_setValue(data) {
|
||||
// abstract
|
||||
if (data !== null && data !== undefined) {
|
||||
if (typeof data !== 'string') {
|
||||
this.reportInvalidData(data);
|
||||
}
|
||||
this._value = data;
|
||||
return;
|
||||
}
|
||||
if (this.environmentVariable !== undefined) {
|
||||
// Try reading the environment variable
|
||||
const environmentValue = process.env[this.environmentVariable];
|
||||
if (environmentValue !== undefined && environmentValue !== '') {
|
||||
if (this.alternatives.indexOf(environmentValue) < 0) {
|
||||
const choices = '"' + this.alternatives.join('", "') + '"';
|
||||
throw new Error(`Invalid value "${environmentValue}" for the environment variable` +
|
||||
` ${this.environmentVariable}. Valid choices are: ${choices}`);
|
||||
}
|
||||
this._value = environmentValue;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.defaultValue !== undefined) {
|
||||
this._value = this.defaultValue;
|
||||
return;
|
||||
}
|
||||
this._value = undefined;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._getSupplementaryNotes}
|
||||
* @internal
|
||||
*/
|
||||
_getSupplementaryNotes(supplementaryNotes) {
|
||||
// virtual
|
||||
super._getSupplementaryNotes(supplementaryNotes);
|
||||
if (this.defaultValue !== undefined) {
|
||||
supplementaryNotes.push(`The default value is "${this.defaultValue}".`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the argument value for a choice parameter that was parsed from the command line.
|
||||
*
|
||||
* @remarks
|
||||
* The return value will be `undefined` if the command-line has not been parsed yet,
|
||||
* or if the parameter was omitted and has no default value.
|
||||
*/
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
||||
appendToArgList(argList) {
|
||||
if (this.value !== undefined) {
|
||||
argList.push(this.longName);
|
||||
argList.push(this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.CommandLineChoiceParameter = CommandLineChoiceParameter;
|
||||
//# sourceMappingURL=CommandLineChoiceParameter.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineChoiceParameter.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineChoiceParameter.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
219
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineDefinition.d.ts
generated
vendored
Normal file
219
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineDefinition.d.ts
generated
vendored
Normal file
@ -0,0 +1,219 @@
|
||||
import type { SCOPING_PARAMETER_GROUP } from '../Constants';
|
||||
/**
|
||||
* For use with CommandLineParser, this interface represents a generic command-line parameter
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface IBaseCommandLineDefinition {
|
||||
/**
|
||||
* The long name of the flag including double dashes, e.g. "--do-something"
|
||||
*/
|
||||
parameterLongName: string;
|
||||
/**
|
||||
* An optional short name for the flag including the dash, e.g. "-d"
|
||||
*/
|
||||
parameterShortName?: string;
|
||||
/**
|
||||
* An optional parameter group name, shown when invoking the tool with "--help"
|
||||
*/
|
||||
parameterGroup?: string | typeof SCOPING_PARAMETER_GROUP;
|
||||
/**
|
||||
* An optional parameter scope name, used to add a scope-prefixed parameter synonym,
|
||||
* e.g. "--scope:do-something". Scopes provide additional flexibility for parameters
|
||||
* in conflict resolution since when a scope is specified, parameters that have
|
||||
* conflicting long names will be defined using only the scope-prefixed name.
|
||||
*/
|
||||
parameterScope?: string;
|
||||
/**
|
||||
* Documentation for the parameter that will be shown when invoking the tool with "--help"
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* If true, then an error occurs if the parameter was not included on the command-line.
|
||||
*/
|
||||
required?: boolean;
|
||||
/**
|
||||
* The name of an environment variable that the parameter value will be read from,
|
||||
* if it was omitted from the command-line. An error will be reported if the
|
||||
* environment value cannot be parsed.
|
||||
*
|
||||
* @remarks
|
||||
* The environment variable name must consist only of upper-case letters, numbers,
|
||||
* and underscores. It may not start with a number.
|
||||
*
|
||||
* This feature cannot be used when {@link IBaseCommandLineDefinition.required} is true,
|
||||
* because in that case the environmentVariable would never be used.
|
||||
*
|
||||
* Syntax notes for environment variable values:
|
||||
*
|
||||
* - Choice Parameter: The value must match one of the defined choices,
|
||||
* otherwise a validation error is reported.
|
||||
* An empty string causes the environment variable to be ignored.
|
||||
*
|
||||
* - Flag Parameter: The value must be `1` for true, or `0` for false,
|
||||
* otherwise a validation error is reported.
|
||||
* An empty string causes the environment variable to be ignored.
|
||||
*
|
||||
* - Integer Parameter: The value must be an integer number,
|
||||
* otherwise a validation error is reported.
|
||||
* An empty string causes the environment variable to be ignored.
|
||||
*
|
||||
* - String Parameter: Any value is accepted, including an empty string.
|
||||
*
|
||||
* - String List Parameter: If the string starts with `[` (ignoring whitespace)
|
||||
* then it will be parsed as a JSON array, whose elements must be strings,
|
||||
* numbers, or boolean values.
|
||||
* If the string does not start with `[`, then it behaves like an
|
||||
* ordinary String Parameter: Any value is accepted, including an empty string.
|
||||
*/
|
||||
environmentVariable?: string;
|
||||
/**
|
||||
* Specifies additional names for this parameter that are accepted but not displayed
|
||||
* in the command line help.
|
||||
*
|
||||
* @remarks
|
||||
* This option can be used in cases where a command-line parameter may have been renamed,
|
||||
* but the developer doesn't want to break backwards compatibility with systems that may
|
||||
* still be using the old name. Only the `parameterLongName` syntax is currently allowed.
|
||||
*/
|
||||
undocumentedSynonyms?: string[];
|
||||
}
|
||||
/**
|
||||
* The common base interface for parameter types that accept an argument.
|
||||
*
|
||||
* @remarks
|
||||
* An argument is an accompanying command-line token, such as "123" in the
|
||||
* example "--max-count 123".
|
||||
* @public
|
||||
*/
|
||||
export interface IBaseCommandLineDefinitionWithArgument extends IBaseCommandLineDefinition {
|
||||
/**
|
||||
* The name of the argument, which will be shown in the command-line help.
|
||||
*
|
||||
* @remarks
|
||||
* For example, if the parameter name is '--count" and the argument name is "NUMBER",
|
||||
* then the command-line help would display "--count NUMBER". The argument name must
|
||||
* be comprised of upper-case letters, numbers, and underscores. It should be kept short.
|
||||
*/
|
||||
argumentName: string;
|
||||
/**
|
||||
* An optional callback that provides a list of custom choices for tab completion.
|
||||
* @remarks
|
||||
* This option is only used when `ICommandLineParserOptions.enableTabCompletionAction`
|
||||
* is enabled.
|
||||
*/
|
||||
completions?: () => Promise<string[]>;
|
||||
}
|
||||
/**
|
||||
* For use with {@link CommandLineParameterProvider.defineChoiceParameter},
|
||||
* this interface defines a command line parameter which is constrained to a list of possible
|
||||
* options.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ICommandLineChoiceDefinition extends IBaseCommandLineDefinition {
|
||||
/**
|
||||
* A list of strings (which contain no spaces), of possible options which can be selected
|
||||
*/
|
||||
alternatives: string[];
|
||||
/**
|
||||
* {@inheritDoc ICommandLineStringDefinition.defaultValue}
|
||||
*/
|
||||
defaultValue?: string;
|
||||
/**
|
||||
* An optional callback that provides a list of custom choices for tab completion.
|
||||
* @remarks
|
||||
* This option is only used when `ICommandLineParserOptions.enableTabCompletionAction`
|
||||
* is enabled.
|
||||
*/
|
||||
completions?: () => Promise<string[]>;
|
||||
}
|
||||
/**
|
||||
* For use with {@link CommandLineParameterProvider.defineChoiceListParameter},
|
||||
* this interface defines a command line parameter which is constrained to a list of possible
|
||||
* options. The parameter can be specified multiple times to build a list.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ICommandLineChoiceListDefinition extends IBaseCommandLineDefinition {
|
||||
/**
|
||||
* A list of strings (which contain no spaces), of possible options which can be selected
|
||||
*/
|
||||
alternatives: string[];
|
||||
/**
|
||||
* An optional callback that provides a list of custom choices for tab completion.
|
||||
* @remarks
|
||||
* This option is only used when `ICommandLineParserOptions.enableTabCompletionAction`
|
||||
* is enabled.
|
||||
*/
|
||||
completions?: () => Promise<string[]>;
|
||||
}
|
||||
/**
|
||||
* For use with {@link CommandLineParameterProvider.defineFlagParameter},
|
||||
* this interface defines a command line parameter that is a boolean flag.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ICommandLineFlagDefinition extends IBaseCommandLineDefinition {
|
||||
}
|
||||
/**
|
||||
* For use with {@link CommandLineParameterProvider.defineIntegerParameter},
|
||||
* this interface defines a command line parameter whose argument is an integer value.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ICommandLineIntegerDefinition extends IBaseCommandLineDefinitionWithArgument {
|
||||
/**
|
||||
* {@inheritDoc ICommandLineStringDefinition.defaultValue}
|
||||
*/
|
||||
defaultValue?: number;
|
||||
}
|
||||
/**
|
||||
* For use with {@link CommandLineParameterProvider.defineIntegerListParameter},
|
||||
* this interface defines a command line parameter whose argument is an integer value. The
|
||||
* parameter can be specified multiple times to build a list.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ICommandLineIntegerListDefinition extends IBaseCommandLineDefinitionWithArgument {
|
||||
}
|
||||
/**
|
||||
* For use with {@link CommandLineParameterProvider.defineStringParameter},
|
||||
* this interface defines a command line parameter whose argument is a string value.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ICommandLineStringDefinition extends IBaseCommandLineDefinitionWithArgument {
|
||||
/**
|
||||
* The default value which will be used if the parameter is omitted from the command line.
|
||||
*
|
||||
* @remarks
|
||||
* If a default value is specified, then {@link IBaseCommandLineDefinition.required}
|
||||
* must not be true. Instead, a custom error message should be used to report cases
|
||||
* where a default value was not available.
|
||||
*/
|
||||
defaultValue?: string;
|
||||
}
|
||||
/**
|
||||
* For use with {@link CommandLineParameterProvider.defineStringListParameter},
|
||||
* this interface defines a command line parameter whose argument is a single text string.
|
||||
* The parameter can be specified multiple times to build a list.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ICommandLineStringListDefinition extends IBaseCommandLineDefinitionWithArgument {
|
||||
}
|
||||
/**
|
||||
* For use with {@link CommandLineParameterProvider.defineCommandLineRemainder},
|
||||
* this interface defines a rule that captures any remaining command line arguments after the recognized portion.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ICommandLineRemainderDefinition {
|
||||
/**
|
||||
* Documentation for how the remaining arguments will be used. This will be shown when invoking
|
||||
* the tool with "--help".
|
||||
*/
|
||||
description: string;
|
||||
}
|
||||
//# sourceMappingURL=CommandLineDefinition.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineDefinition.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineDefinition.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineDefinition.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineDefinition.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE5D;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,uBAAuB,CAAC;IAEzD;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;;;;;;OAQG;IACH,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,sCAAuC,SAAQ,0BAA0B;IACxF;;;;;;;OAOG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,4BAA6B,SAAQ,0BAA0B;IAC9E;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gCAAiC,SAAQ,0BAA0B;IAClF;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;GAKG;AACH,MAAM,WAAW,0BAA2B,SAAQ,0BAA0B;CAAG;AAEjF;;;;;GAKG;AACH,MAAM,WAAW,6BAA8B,SAAQ,sCAAsC;IAC3F;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iCAAkC,SAAQ,sCAAsC;CAAG;AAEpG;;;;;GAKG;AACH,MAAM,WAAW,4BAA6B,SAAQ,sCAAsC;IAC1F;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gCAAiC,SAAQ,sCAAsC;CAAG;AAEnG;;;;;GAKG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
5
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineDefinition.js
generated
vendored
Normal file
5
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineDefinition.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=CommandLineDefinition.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineDefinition.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineDefinition.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
29
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineFlagParameter.d.ts
generated
vendored
Normal file
29
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineFlagParameter.d.ts
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
import type { ICommandLineFlagDefinition } from './CommandLineDefinition';
|
||||
import { CommandLineParameter, CommandLineParameterKind } from './BaseClasses';
|
||||
/**
|
||||
* The data type returned by {@link CommandLineParameterProvider.defineFlagParameter}.
|
||||
* @public
|
||||
*/
|
||||
export declare class CommandLineFlagParameter extends CommandLineParameter {
|
||||
private _value;
|
||||
/** @internal */
|
||||
constructor(definition: ICommandLineFlagDefinition);
|
||||
/** {@inheritDoc CommandLineParameter.kind} */
|
||||
get kind(): CommandLineParameterKind;
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._setValue}
|
||||
* @internal
|
||||
*/
|
||||
_setValue(data: any): void;
|
||||
/**
|
||||
* Returns a boolean indicating whether the parameter was included in the command line.
|
||||
*
|
||||
* @remarks
|
||||
* The return value will be false if the command-line has not been parsed yet,
|
||||
* or if the flag was not used.
|
||||
*/
|
||||
get value(): boolean;
|
||||
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
||||
appendToArgList(argList: string[]): void;
|
||||
}
|
||||
//# sourceMappingURL=CommandLineFlagParameter.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineFlagParameter.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineFlagParameter.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineFlagParameter.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineFlagParameter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAE/E;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,oBAAoB;IAChE,OAAO,CAAC,MAAM,CAAkB;IAEhC,gBAAgB;gBACG,UAAU,EAAE,0BAA0B;IAIzD,8CAA8C;IAC9C,IAAW,IAAI,IAAI,wBAAwB,CAE1C;IAED;;;OAGG;IAEI,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAkCjC;;;;;;OAMG;IACH,IAAW,KAAK,IAAI,OAAO,CAE1B;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;CAKhD"}
|
72
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineFlagParameter.js
generated
vendored
Normal file
72
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineFlagParameter.js
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CommandLineFlagParameter = void 0;
|
||||
const BaseClasses_1 = require("./BaseClasses");
|
||||
/**
|
||||
* The data type returned by {@link CommandLineParameterProvider.defineFlagParameter}.
|
||||
* @public
|
||||
*/
|
||||
class CommandLineFlagParameter extends BaseClasses_1.CommandLineParameter {
|
||||
/** @internal */
|
||||
constructor(definition) {
|
||||
super(definition);
|
||||
this._value = false;
|
||||
}
|
||||
/** {@inheritDoc CommandLineParameter.kind} */
|
||||
get kind() {
|
||||
return BaseClasses_1.CommandLineParameterKind.Flag;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._setValue}
|
||||
* @internal
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
_setValue(data) {
|
||||
// abstract
|
||||
if (data !== null && data !== undefined) {
|
||||
if (typeof data !== 'boolean') {
|
||||
this.reportInvalidData(data);
|
||||
}
|
||||
// If the flag is omitted, then argparse sets the data to "false" instead of "undefined".
|
||||
// This design prevents a syntax such as "--flag=false", probably because argparse prefers "--no-flag".
|
||||
// If we switch to a new CLI parser, we should try to add support for "--flag=false".
|
||||
if (data) {
|
||||
this._value = data;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.environmentVariable !== undefined) {
|
||||
// Try reading the environment variable
|
||||
const environmentValue = process.env[this.environmentVariable];
|
||||
if (environmentValue !== undefined && environmentValue !== '') {
|
||||
if (environmentValue !== '0' && environmentValue !== '1') {
|
||||
throw new Error(`Invalid value "${environmentValue}" for the environment variable` +
|
||||
` ${this.environmentVariable}. Valid choices are 0 or 1.`);
|
||||
}
|
||||
this._value = environmentValue === '1';
|
||||
return;
|
||||
}
|
||||
}
|
||||
this._value = false;
|
||||
}
|
||||
/**
|
||||
* Returns a boolean indicating whether the parameter was included in the command line.
|
||||
*
|
||||
* @remarks
|
||||
* The return value will be false if the command-line has not been parsed yet,
|
||||
* or if the flag was not used.
|
||||
*/
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
||||
appendToArgList(argList) {
|
||||
if (this.value) {
|
||||
argList.push(this.longName);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.CommandLineFlagParameter = CommandLineFlagParameter;
|
||||
//# sourceMappingURL=CommandLineFlagParameter.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineFlagParameter.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineFlagParameter.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineFlagParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineFlagParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA+E;AAE/E;;;GAGG;AACH,MAAa,wBAAyB,SAAQ,kCAAoB;IAGhE,gBAAgB;IAChB,YAAmB,UAAsC;QACvD,KAAK,CAAC,UAAU,CAAC,CAAC;QAJZ,WAAM,GAAY,KAAK,CAAC;IAKhC,CAAC;IAED,8CAA8C;IAC9C,IAAW,IAAI;QACb,OAAO,sCAAwB,CAAC,IAAI,CAAC;IACvC,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,WAAW;QACX,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACvC,IAAI,OAAO,IAAI,KAAK,SAAS,EAAE;gBAC7B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;aAC9B;YAED,yFAAyF;YACzF,uGAAuG;YACvG,qFAAqF;YACrF,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;gBACnB,OAAO;aACR;SACF;QAED,IAAI,IAAI,CAAC,mBAAmB,KAAK,SAAS,EAAE;YAC1C,uCAAuC;YACvC,MAAM,gBAAgB,GAAuB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACnF,IAAI,gBAAgB,KAAK,SAAS,IAAI,gBAAgB,KAAK,EAAE,EAAE;gBAC7D,IAAI,gBAAgB,KAAK,GAAG,IAAI,gBAAgB,KAAK,GAAG,EAAE;oBACxD,MAAM,IAAI,KAAK,CACb,kBAAkB,gBAAgB,gCAAgC;wBAChE,IAAI,IAAI,CAAC,mBAAmB,8BAA8B,CAC7D,CAAC;iBACH;gBACD,IAAI,CAAC,MAAM,GAAG,gBAAgB,KAAK,GAAG,CAAC;gBACvC,OAAO;aACR;SACF;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC7B;IACH,CAAC;CACF;AArED,4DAqEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ICommandLineFlagDefinition } from './CommandLineDefinition';\nimport { CommandLineParameter, CommandLineParameterKind } from './BaseClasses';\n\n/**\n * The data type returned by {@link CommandLineParameterProvider.defineFlagParameter}.\n * @public\n */\nexport class CommandLineFlagParameter extends CommandLineParameter {\n private _value: boolean = false;\n\n /** @internal */\n public constructor(definition: ICommandLineFlagDefinition) {\n super(definition);\n }\n\n /** {@inheritDoc CommandLineParameter.kind} */\n public get kind(): CommandLineParameterKind {\n return CommandLineParameterKind.Flag;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._setValue}\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public _setValue(data: any): void {\n // abstract\n if (data !== null && data !== undefined) {\n if (typeof data !== 'boolean') {\n this.reportInvalidData(data);\n }\n\n // If the flag is omitted, then argparse sets the data to \"false\" instead of \"undefined\".\n // This design prevents a syntax such as \"--flag=false\", probably because argparse prefers \"--no-flag\".\n // If we switch to a new CLI parser, we should try to add support for \"--flag=false\".\n if (data) {\n this._value = data;\n return;\n }\n }\n\n if (this.environmentVariable !== undefined) {\n // Try reading the environment variable\n const environmentValue: string | undefined = process.env[this.environmentVariable];\n if (environmentValue !== undefined && environmentValue !== '') {\n if (environmentValue !== '0' && environmentValue !== '1') {\n throw new Error(\n `Invalid value \"${environmentValue}\" for the environment variable` +\n ` ${this.environmentVariable}. Valid choices are 0 or 1.`\n );\n }\n this._value = environmentValue === '1';\n return;\n }\n }\n\n this._value = false;\n }\n\n /**\n * Returns a boolean indicating whether the parameter was included in the command line.\n *\n * @remarks\n * The return value will be false if the command-line has not been parsed yet,\n * or if the flag was not used.\n */\n public get value(): boolean {\n return this._value;\n }\n\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\n public appendToArgList(argList: string[]): void {\n if (this.value) {\n argList.push(this.longName);\n }\n }\n}\n"]}
|
29
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineIntegerListParameter.d.ts
generated
vendored
Normal file
29
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineIntegerListParameter.d.ts
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
import type { ICommandLineIntegerListDefinition } from './CommandLineDefinition';
|
||||
import { CommandLineParameterWithArgument, CommandLineParameterKind } from './BaseClasses';
|
||||
/**
|
||||
* The data type returned by {@link CommandLineParameterProvider.defineIntegerListParameter}.
|
||||
* @public
|
||||
*/
|
||||
export declare class CommandLineIntegerListParameter extends CommandLineParameterWithArgument {
|
||||
private _values;
|
||||
/** @internal */
|
||||
constructor(definition: ICommandLineIntegerListDefinition);
|
||||
/** {@inheritDoc CommandLineParameter.kind} */
|
||||
get kind(): CommandLineParameterKind;
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._setValue}
|
||||
* @internal
|
||||
*/
|
||||
_setValue(data: any): void;
|
||||
/**
|
||||
* Returns the integer arguments for an integer list parameter that was parsed from the command line.
|
||||
*
|
||||
* @remarks
|
||||
* The array will be empty if the command-line has not been parsed yet,
|
||||
* or if the parameter was omitted and has no default value.
|
||||
*/
|
||||
get values(): ReadonlyArray<number>;
|
||||
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
||||
appendToArgList(argList: string[]): void;
|
||||
}
|
||||
//# sourceMappingURL=CommandLineIntegerListParameter.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineIntegerListParameter.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineIntegerListParameter.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineIntegerListParameter.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineIntegerListParameter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAAE,gCAAgC,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAG3F;;;GAGG;AACH,qBAAa,+BAAgC,SAAQ,gCAAgC;IACnF,OAAO,CAAC,OAAO,CAAgB;IAE/B,gBAAgB;gBACG,UAAU,EAAE,iCAAiC;IAIhE,8CAA8C;IAC9C,IAAW,IAAI,IAAI,wBAAwB,CAE1C;IAED;;;OAGG;IAEI,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAwCjC;;;;;;OAMG;IACH,IAAW,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,CAEzC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;CAQhD"}
|
82
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineIntegerListParameter.js
generated
vendored
Normal file
82
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineIntegerListParameter.js
generated
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CommandLineIntegerListParameter = void 0;
|
||||
const BaseClasses_1 = require("./BaseClasses");
|
||||
const EnvironmentVariableParser_1 = require("./EnvironmentVariableParser");
|
||||
/**
|
||||
* The data type returned by {@link CommandLineParameterProvider.defineIntegerListParameter}.
|
||||
* @public
|
||||
*/
|
||||
class CommandLineIntegerListParameter extends BaseClasses_1.CommandLineParameterWithArgument {
|
||||
/** @internal */
|
||||
constructor(definition) {
|
||||
super(definition);
|
||||
this._values = [];
|
||||
}
|
||||
/** {@inheritDoc CommandLineParameter.kind} */
|
||||
get kind() {
|
||||
return BaseClasses_1.CommandLineParameterKind.IntegerList;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._setValue}
|
||||
* @internal
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
_setValue(data) {
|
||||
// If argparse passed us a value, confirm it is valid
|
||||
if (data !== null && data !== undefined) {
|
||||
if (!Array.isArray(data)) {
|
||||
this.reportInvalidData(data);
|
||||
}
|
||||
for (const arrayItem of data) {
|
||||
if (typeof arrayItem !== 'number') {
|
||||
this.reportInvalidData(data);
|
||||
}
|
||||
}
|
||||
this._values = data;
|
||||
return;
|
||||
}
|
||||
// If an environment variable exists, attempt to parse it as a list
|
||||
if (this.environmentVariable !== undefined) {
|
||||
const values = EnvironmentVariableParser_1.EnvironmentVariableParser.parseAsList(this.environmentVariable);
|
||||
if (values) {
|
||||
const parsedValues = [];
|
||||
for (const value of values) {
|
||||
const parsed = parseInt(value, 10);
|
||||
if (isNaN(parsed) || value.indexOf('.') >= 0) {
|
||||
throw new Error(`Invalid value "${value}" for the environment variable` +
|
||||
` ${this.environmentVariable}. It must be an integer value.`);
|
||||
}
|
||||
parsedValues.push(parsed);
|
||||
}
|
||||
this._values = parsedValues;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// (No default value for integer lists)
|
||||
this._values = [];
|
||||
}
|
||||
/**
|
||||
* Returns the integer arguments for an integer list parameter that was parsed from the command line.
|
||||
*
|
||||
* @remarks
|
||||
* The array will be empty if the command-line has not been parsed yet,
|
||||
* or if the parameter was omitted and has no default value.
|
||||
*/
|
||||
get values() {
|
||||
return this._values;
|
||||
}
|
||||
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
||||
appendToArgList(argList) {
|
||||
if (this.values.length > 0) {
|
||||
for (const value of this.values) {
|
||||
argList.push(this.longName);
|
||||
argList.push(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.CommandLineIntegerListParameter = CommandLineIntegerListParameter;
|
||||
//# sourceMappingURL=CommandLineIntegerListParameter.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineIntegerListParameter.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineIntegerListParameter.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineIntegerListParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineIntegerListParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA2F;AAC3F,2EAAwE;AAExE;;;GAGG;AACH,MAAa,+BAAgC,SAAQ,8CAAgC;IAGnF,gBAAgB;IAChB,YAAmB,UAA6C;QAC9D,KAAK,CAAC,UAAU,CAAC,CAAC;QAJZ,YAAO,GAAa,EAAE,CAAC;IAK/B,CAAC;IAED,8CAA8C;IAC9C,IAAW,IAAI;QACb,OAAO,sCAAwB,CAAC,WAAW,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,qDAAqD;QACrD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACvC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACxB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;aAC9B;YACD,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE;gBAC5B,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;oBACjC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;iBAC9B;aACF;YACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,OAAO;SACR;QAED,mEAAmE;QACnE,IAAI,IAAI,CAAC,mBAAmB,KAAK,SAAS,EAAE;YAC1C,MAAM,MAAM,GAAyB,qDAAyB,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACrG,IAAI,MAAM,EAAE;gBACV,MAAM,YAAY,GAAa,EAAE,CAAC;gBAClC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;oBAC1B,MAAM,MAAM,GAAW,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;oBAC3C,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;wBAC5C,MAAM,IAAI,KAAK,CACb,kBAAkB,KAAK,gCAAgC;4BACrD,IAAI,IAAI,CAAC,mBAAmB,iCAAiC,CAChE,CAAC;qBACH;oBACD,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;iBAC3B;gBACD,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC;gBAC5B,OAAO;aACR;SACF;QAED,uCAAuC;QAEvC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;gBAC/B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;aAChC;SACF;IACH,CAAC;CACF;AA9ED,0EA8EC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ICommandLineIntegerListDefinition } from './CommandLineDefinition';\nimport { CommandLineParameterWithArgument, CommandLineParameterKind } from './BaseClasses';\nimport { EnvironmentVariableParser } from './EnvironmentVariableParser';\n\n/**\n * The data type returned by {@link CommandLineParameterProvider.defineIntegerListParameter}.\n * @public\n */\nexport class CommandLineIntegerListParameter extends CommandLineParameterWithArgument {\n private _values: number[] = [];\n\n /** @internal */\n public constructor(definition: ICommandLineIntegerListDefinition) {\n super(definition);\n }\n\n /** {@inheritDoc CommandLineParameter.kind} */\n public get kind(): CommandLineParameterKind {\n return CommandLineParameterKind.IntegerList;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._setValue}\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public _setValue(data: any): void {\n // If argparse passed us a value, confirm it is valid\n if (data !== null && data !== undefined) {\n if (!Array.isArray(data)) {\n this.reportInvalidData(data);\n }\n for (const arrayItem of data) {\n if (typeof arrayItem !== 'number') {\n this.reportInvalidData(data);\n }\n }\n this._values = data;\n return;\n }\n\n // If an environment variable exists, attempt to parse it as a list\n if (this.environmentVariable !== undefined) {\n const values: string[] | undefined = EnvironmentVariableParser.parseAsList(this.environmentVariable);\n if (values) {\n const parsedValues: number[] = [];\n for (const value of values) {\n const parsed: number = parseInt(value, 10);\n if (isNaN(parsed) || value.indexOf('.') >= 0) {\n throw new Error(\n `Invalid value \"${value}\" for the environment variable` +\n ` ${this.environmentVariable}. It must be an integer value.`\n );\n }\n parsedValues.push(parsed);\n }\n this._values = parsedValues;\n return;\n }\n }\n\n // (No default value for integer lists)\n\n this._values = [];\n }\n\n /**\n * Returns the integer arguments for an integer list parameter that was parsed from the command line.\n *\n * @remarks\n * The array will be empty if the command-line has not been parsed yet,\n * or if the parameter was omitted and has no default value.\n */\n public get values(): ReadonlyArray<number> {\n return this._values;\n }\n\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\n public appendToArgList(argList: string[]): void {\n if (this.values.length > 0) {\n for (const value of this.values) {\n argList.push(this.longName);\n argList.push(value.toString());\n }\n }\n }\n}\n"]}
|
36
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineIntegerParameter.d.ts
generated
vendored
Normal file
36
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineIntegerParameter.d.ts
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
import type { ICommandLineIntegerDefinition } from './CommandLineDefinition';
|
||||
import { CommandLineParameterWithArgument, CommandLineParameterKind } from './BaseClasses';
|
||||
/**
|
||||
* The data type returned by {@link CommandLineParameterProvider.defineIntegerParameter}.
|
||||
* @public
|
||||
*/
|
||||
export declare class CommandLineIntegerParameter extends CommandLineParameterWithArgument {
|
||||
/** {@inheritDoc ICommandLineStringDefinition.defaultValue} */
|
||||
readonly defaultValue: number | undefined;
|
||||
private _value;
|
||||
/** @internal */
|
||||
constructor(definition: ICommandLineIntegerDefinition);
|
||||
/** {@inheritDoc CommandLineParameter.kind} */
|
||||
get kind(): CommandLineParameterKind;
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._setValue}
|
||||
* @internal
|
||||
*/
|
||||
_setValue(data: any): void;
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._getSupplementaryNotes}
|
||||
* @internal
|
||||
*/
|
||||
_getSupplementaryNotes(supplementaryNotes: string[]): void;
|
||||
/**
|
||||
* Returns the argument value for an integer parameter that was parsed from the command line.
|
||||
*
|
||||
* @remarks
|
||||
* The return value will be undefined if the command-line has not been parsed yet,
|
||||
* or if the parameter was omitted and has no default value.
|
||||
*/
|
||||
get value(): number | undefined;
|
||||
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
||||
appendToArgList(argList: string[]): void;
|
||||
}
|
||||
//# sourceMappingURL=CommandLineIntegerParameter.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineIntegerParameter.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineIntegerParameter.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineIntegerParameter.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineIntegerParameter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,gCAAgC,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAE3F;;;GAGG;AACH,qBAAa,2BAA4B,SAAQ,gCAAgC;IAC/E,8DAA8D;IAC9D,SAAgB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjD,OAAO,CAAC,MAAM,CAAiC;IAE/C,gBAAgB;gBACG,UAAU,EAAE,6BAA6B;IAM5D,8CAA8C;IAC9C,IAAW,IAAI,IAAI,wBAAwB,CAE1C;IAED;;;OAGG;IAEI,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAkCjC;;;OAGG;IACI,sBAAsB,CAAC,kBAAkB,EAAE,MAAM,EAAE,GAAG,IAAI;IAQjE;;;;;;OAMG;IACH,IAAW,KAAK,IAAI,MAAM,GAAG,SAAS,CAErC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;CAMhD"}
|
86
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineIntegerParameter.js
generated
vendored
Normal file
86
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineIntegerParameter.js
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CommandLineIntegerParameter = void 0;
|
||||
const BaseClasses_1 = require("./BaseClasses");
|
||||
/**
|
||||
* The data type returned by {@link CommandLineParameterProvider.defineIntegerParameter}.
|
||||
* @public
|
||||
*/
|
||||
class CommandLineIntegerParameter extends BaseClasses_1.CommandLineParameterWithArgument {
|
||||
/** @internal */
|
||||
constructor(definition) {
|
||||
super(definition);
|
||||
this._value = undefined;
|
||||
this.defaultValue = definition.defaultValue;
|
||||
this.validateDefaultValue(!!this.defaultValue);
|
||||
}
|
||||
/** {@inheritDoc CommandLineParameter.kind} */
|
||||
get kind() {
|
||||
return BaseClasses_1.CommandLineParameterKind.Integer;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._setValue}
|
||||
* @internal
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
_setValue(data) {
|
||||
// abstract
|
||||
if (data !== null && data !== undefined) {
|
||||
if (typeof data !== 'number') {
|
||||
this.reportInvalidData(data);
|
||||
}
|
||||
this._value = data;
|
||||
return;
|
||||
}
|
||||
if (this.environmentVariable !== undefined) {
|
||||
// Try reading the environment variable
|
||||
const environmentValue = process.env[this.environmentVariable];
|
||||
if (environmentValue !== undefined && environmentValue !== '') {
|
||||
const parsed = parseInt(environmentValue, 10);
|
||||
if (isNaN(parsed) || environmentValue.indexOf('.') >= 0) {
|
||||
throw new Error(`Invalid value "${environmentValue}" for the environment variable` +
|
||||
` ${this.environmentVariable}. It must be an integer value.`);
|
||||
}
|
||||
this._value = parsed;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.defaultValue !== undefined) {
|
||||
this._value = this.defaultValue;
|
||||
return;
|
||||
}
|
||||
this._value = undefined;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._getSupplementaryNotes}
|
||||
* @internal
|
||||
*/
|
||||
_getSupplementaryNotes(supplementaryNotes) {
|
||||
// virtual
|
||||
super._getSupplementaryNotes(supplementaryNotes);
|
||||
if (this.defaultValue !== undefined) {
|
||||
supplementaryNotes.push(`The default value is ${this.defaultValue}.`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the argument value for an integer parameter that was parsed from the command line.
|
||||
*
|
||||
* @remarks
|
||||
* The return value will be undefined if the command-line has not been parsed yet,
|
||||
* or if the parameter was omitted and has no default value.
|
||||
*/
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
||||
appendToArgList(argList) {
|
||||
if (this.value !== undefined) {
|
||||
argList.push(this.longName);
|
||||
argList.push(this.value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.CommandLineIntegerParameter = CommandLineIntegerParameter;
|
||||
//# sourceMappingURL=CommandLineIntegerParameter.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineIntegerParameter.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineIntegerParameter.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
28
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineRemainder.d.ts
generated
vendored
Normal file
28
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineRemainder.d.ts
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
import type { ICommandLineRemainderDefinition } from './CommandLineDefinition';
|
||||
/**
|
||||
* The data type returned by {@link CommandLineParameterProvider.defineCommandLineRemainder}.
|
||||
* @public
|
||||
*/
|
||||
export declare class CommandLineRemainder {
|
||||
private _values;
|
||||
/** {@inheritDoc IBaseCommandLineDefinition.description} */
|
||||
readonly description: string;
|
||||
/** @internal */
|
||||
constructor(definition: ICommandLineRemainderDefinition);
|
||||
/**
|
||||
* Returns any remaining command line arguments after the recognized portion
|
||||
* that was parsed from the command line.
|
||||
*
|
||||
* @remarks
|
||||
* The array will be empty if the command-line has not been parsed yet.
|
||||
*/
|
||||
get values(): ReadonlyArray<string>;
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._setValue}
|
||||
* @internal
|
||||
*/
|
||||
_setValue(data: any): void;
|
||||
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
||||
appendToArgList(argList: string[]): void;
|
||||
}
|
||||
//# sourceMappingURL=CommandLineRemainder.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineRemainder.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineRemainder.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineRemainder.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineRemainder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAE/E;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,OAAO,CAAgB;IAE/B,2DAA2D;IAC3D,SAAgB,WAAW,EAAE,MAAM,CAAC;IAEpC,gBAAgB;gBACG,UAAU,EAAE,+BAA+B;IAI9D;;;;;;OAMG;IACH,IAAW,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,CAEzC;IAED;;;OAGG;IAEI,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IASjC,mEAAmE;IAC5D,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;CAOhD"}
|
48
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineRemainder.js
generated
vendored
Normal file
48
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineRemainder.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CommandLineRemainder = void 0;
|
||||
/**
|
||||
* The data type returned by {@link CommandLineParameterProvider.defineCommandLineRemainder}.
|
||||
* @public
|
||||
*/
|
||||
class CommandLineRemainder {
|
||||
/** @internal */
|
||||
constructor(definition) {
|
||||
this._values = [];
|
||||
this.description = definition.description;
|
||||
}
|
||||
/**
|
||||
* Returns any remaining command line arguments after the recognized portion
|
||||
* that was parsed from the command line.
|
||||
*
|
||||
* @remarks
|
||||
* The array will be empty if the command-line has not been parsed yet.
|
||||
*/
|
||||
get values() {
|
||||
return this._values;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._setValue}
|
||||
* @internal
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
_setValue(data) {
|
||||
// abstract
|
||||
if (!Array.isArray(data) || !data.every((x) => typeof x === 'string')) {
|
||||
throw new Error(`Unexpected data object for remainder: ` + JSON.stringify(data));
|
||||
}
|
||||
this._values.push(...data);
|
||||
}
|
||||
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
||||
appendToArgList(argList) {
|
||||
if (this.values.length > 0) {
|
||||
for (const value of this.values) {
|
||||
argList.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.CommandLineRemainder = CommandLineRemainder;
|
||||
//# sourceMappingURL=CommandLineRemainder.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineRemainder.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineRemainder.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineRemainder.js","sourceRoot":"","sources":["../../src/parameters/CommandLineRemainder.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D;;;GAGG;AACH,MAAa,oBAAoB;IAM/B,gBAAgB;IAChB,YAAmB,UAA2C;QANtD,YAAO,GAAa,EAAE,CAAC;QAO7B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;IAC5C,CAAC;IAED;;;;;;OAMG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,WAAW;QACX,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,EAAE;YACrE,MAAM,IAAI,KAAK,CAAC,wCAAwC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;SAClF;QAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;gBAC/B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACrB;SACF;IACH,CAAC;CACF;AA5CD,oDA4CC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ICommandLineRemainderDefinition } from './CommandLineDefinition';\n\n/**\n * The data type returned by {@link CommandLineParameterProvider.defineCommandLineRemainder}.\n * @public\n */\nexport class CommandLineRemainder {\n private _values: string[] = [];\n\n /** {@inheritDoc IBaseCommandLineDefinition.description} */\n public readonly description: string;\n\n /** @internal */\n public constructor(definition: ICommandLineRemainderDefinition) {\n this.description = definition.description;\n }\n\n /**\n * Returns any remaining command line arguments after the recognized portion\n * that was parsed from the command line.\n *\n * @remarks\n * The array will be empty if the command-line has not been parsed yet.\n */\n public get values(): ReadonlyArray<string> {\n return this._values;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._setValue}\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public _setValue(data: any): void {\n // abstract\n if (!Array.isArray(data) || !data.every((x) => typeof x === 'string')) {\n throw new Error(`Unexpected data object for remainder: ` + JSON.stringify(data));\n }\n\n this._values.push(...data);\n }\n\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\n public appendToArgList(argList: string[]): void {\n if (this.values.length > 0) {\n for (const value of this.values) {\n argList.push(value);\n }\n }\n }\n}\n"]}
|
29
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineStringListParameter.d.ts
generated
vendored
Normal file
29
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineStringListParameter.d.ts
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
import type { ICommandLineStringListDefinition } from './CommandLineDefinition';
|
||||
import { CommandLineParameterWithArgument, CommandLineParameterKind } from './BaseClasses';
|
||||
/**
|
||||
* The data type returned by {@link CommandLineParameterProvider.defineStringListParameter}.
|
||||
* @public
|
||||
*/
|
||||
export declare class CommandLineStringListParameter extends CommandLineParameterWithArgument {
|
||||
private _values;
|
||||
/** @internal */
|
||||
constructor(definition: ICommandLineStringListDefinition);
|
||||
/** {@inheritDoc CommandLineParameter.kind} */
|
||||
get kind(): CommandLineParameterKind;
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._setValue}
|
||||
* @internal
|
||||
*/
|
||||
_setValue(data: any): void;
|
||||
/**
|
||||
* Returns the string arguments for a string list parameter that was parsed from the command line.
|
||||
*
|
||||
* @remarks
|
||||
* The array will be empty if the command-line has not been parsed yet,
|
||||
* or if the parameter was omitted and has no default value.
|
||||
*/
|
||||
get values(): ReadonlyArray<string>;
|
||||
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
||||
appendToArgList(argList: string[]): void;
|
||||
}
|
||||
//# sourceMappingURL=CommandLineStringListParameter.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineStringListParameter.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineStringListParameter.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineStringListParameter.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineStringListParameter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,gCAAgC,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAG3F;;;GAGG;AACH,qBAAa,8BAA+B,SAAQ,gCAAgC;IAClF,OAAO,CAAC,OAAO,CAAgB;IAE/B,gBAAgB;gBACG,UAAU,EAAE,gCAAgC;IAI/D,8CAA8C;IAC9C,IAAW,IAAI,IAAI,wBAAwB,CAE1C;IAED;;;OAGG;IAEI,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IA6BjC;;;;;;OAMG;IACH,IAAW,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,CAEzC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;CAQhD"}
|
73
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineStringListParameter.js
generated
vendored
Normal file
73
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineStringListParameter.js
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CommandLineStringListParameter = void 0;
|
||||
const BaseClasses_1 = require("./BaseClasses");
|
||||
const EnvironmentVariableParser_1 = require("./EnvironmentVariableParser");
|
||||
/**
|
||||
* The data type returned by {@link CommandLineParameterProvider.defineStringListParameter}.
|
||||
* @public
|
||||
*/
|
||||
class CommandLineStringListParameter extends BaseClasses_1.CommandLineParameterWithArgument {
|
||||
/** @internal */
|
||||
constructor(definition) {
|
||||
super(definition);
|
||||
this._values = [];
|
||||
}
|
||||
/** {@inheritDoc CommandLineParameter.kind} */
|
||||
get kind() {
|
||||
return BaseClasses_1.CommandLineParameterKind.StringList;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._setValue}
|
||||
* @internal
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
_setValue(data) {
|
||||
// If argparse passed us a value, confirm it is valid
|
||||
if (data !== null && data !== undefined) {
|
||||
if (!Array.isArray(data)) {
|
||||
this.reportInvalidData(data);
|
||||
}
|
||||
for (const arrayItem of data) {
|
||||
if (typeof arrayItem !== 'string') {
|
||||
this.reportInvalidData(data);
|
||||
}
|
||||
}
|
||||
this._values = data;
|
||||
return;
|
||||
}
|
||||
// If an environment variable exists, attempt to parse it as a list
|
||||
if (this.environmentVariable !== undefined) {
|
||||
const values = EnvironmentVariableParser_1.EnvironmentVariableParser.parseAsList(this.environmentVariable);
|
||||
if (values) {
|
||||
this._values = values;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// (No default value for string lists)
|
||||
this._values = [];
|
||||
}
|
||||
/**
|
||||
* Returns the string arguments for a string list parameter that was parsed from the command line.
|
||||
*
|
||||
* @remarks
|
||||
* The array will be empty if the command-line has not been parsed yet,
|
||||
* or if the parameter was omitted and has no default value.
|
||||
*/
|
||||
get values() {
|
||||
return this._values;
|
||||
}
|
||||
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
||||
appendToArgList(argList) {
|
||||
if (this.values.length > 0) {
|
||||
for (const value of this.values) {
|
||||
argList.push(this.longName);
|
||||
argList.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.CommandLineStringListParameter = CommandLineStringListParameter;
|
||||
//# sourceMappingURL=CommandLineStringListParameter.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineStringListParameter.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineStringListParameter.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineStringListParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineStringListParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA2F;AAC3F,2EAAwE;AAExE;;;GAGG;AACH,MAAa,8BAA+B,SAAQ,8CAAgC;IAGlF,gBAAgB;IAChB,YAAmB,UAA4C;QAC7D,KAAK,CAAC,UAAU,CAAC,CAAC;QAJZ,YAAO,GAAa,EAAE,CAAC;IAK/B,CAAC;IAED,8CAA8C;IAC9C,IAAW,IAAI;QACb,OAAO,sCAAwB,CAAC,UAAU,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,qDAAqD;QACrD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACvC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACxB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;aAC9B;YACD,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE;gBAC5B,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;oBACjC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;iBAC9B;aACF;YACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,OAAO;SACR;QAED,mEAAmE;QACnE,IAAI,IAAI,CAAC,mBAAmB,KAAK,SAAS,EAAE;YAC1C,MAAM,MAAM,GAAyB,qDAAyB,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACrG,IAAI,MAAM,EAAE;gBACV,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;gBACtB,OAAO;aACR;SACF;QAED,sCAAsC;QAEtC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;gBAC/B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACrB;SACF;IACH,CAAC;CACF;AAnED,wEAmEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ICommandLineStringListDefinition } from './CommandLineDefinition';\nimport { CommandLineParameterWithArgument, CommandLineParameterKind } from './BaseClasses';\nimport { EnvironmentVariableParser } from './EnvironmentVariableParser';\n\n/**\n * The data type returned by {@link CommandLineParameterProvider.defineStringListParameter}.\n * @public\n */\nexport class CommandLineStringListParameter extends CommandLineParameterWithArgument {\n private _values: string[] = [];\n\n /** @internal */\n public constructor(definition: ICommandLineStringListDefinition) {\n super(definition);\n }\n\n /** {@inheritDoc CommandLineParameter.kind} */\n public get kind(): CommandLineParameterKind {\n return CommandLineParameterKind.StringList;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._setValue}\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public _setValue(data: any): void {\n // If argparse passed us a value, confirm it is valid\n if (data !== null && data !== undefined) {\n if (!Array.isArray(data)) {\n this.reportInvalidData(data);\n }\n for (const arrayItem of data) {\n if (typeof arrayItem !== 'string') {\n this.reportInvalidData(data);\n }\n }\n this._values = data;\n return;\n }\n\n // If an environment variable exists, attempt to parse it as a list\n if (this.environmentVariable !== undefined) {\n const values: string[] | undefined = EnvironmentVariableParser.parseAsList(this.environmentVariable);\n if (values) {\n this._values = values;\n return;\n }\n }\n\n // (No default value for string lists)\n\n this._values = [];\n }\n\n /**\n * Returns the string arguments for a string list parameter that was parsed from the command line.\n *\n * @remarks\n * The array will be empty if the command-line has not been parsed yet,\n * or if the parameter was omitted and has no default value.\n */\n public get values(): ReadonlyArray<string> {\n return this._values;\n }\n\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\n public appendToArgList(argList: string[]): void {\n if (this.values.length > 0) {\n for (const value of this.values) {\n argList.push(this.longName);\n argList.push(value);\n }\n }\n }\n}\n"]}
|
36
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineStringParameter.d.ts
generated
vendored
Normal file
36
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineStringParameter.d.ts
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
import type { ICommandLineStringDefinition } from './CommandLineDefinition';
|
||||
import { CommandLineParameterWithArgument, CommandLineParameterKind } from './BaseClasses';
|
||||
/**
|
||||
* The data type returned by {@link CommandLineParameterProvider.defineStringParameter}.
|
||||
* @public
|
||||
*/
|
||||
export declare class CommandLineStringParameter extends CommandLineParameterWithArgument {
|
||||
/** {@inheritDoc ICommandLineStringDefinition.defaultValue} */
|
||||
readonly defaultValue: string | undefined;
|
||||
private _value;
|
||||
/** @internal */
|
||||
constructor(definition: ICommandLineStringDefinition);
|
||||
/** {@inheritDoc CommandLineParameter.kind} */
|
||||
get kind(): CommandLineParameterKind;
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._setValue}
|
||||
* @internal
|
||||
*/
|
||||
_setValue(data: any): void;
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._getSupplementaryNotes}
|
||||
* @internal
|
||||
*/
|
||||
_getSupplementaryNotes(supplementaryNotes: string[]): void;
|
||||
/**
|
||||
* Returns the argument value for a string parameter that was parsed from the command line.
|
||||
*
|
||||
* @remarks
|
||||
* The return value will be undefined if the command-line has not been parsed yet,
|
||||
* or if the parameter was omitted and has no default value.
|
||||
*/
|
||||
get value(): string | undefined;
|
||||
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
||||
appendToArgList(argList: string[]): void;
|
||||
}
|
||||
//# sourceMappingURL=CommandLineStringParameter.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineStringParameter.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineStringParameter.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineStringParameter.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineStringParameter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,gCAAgC,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAE3F;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,gCAAgC;IAC9E,8DAA8D;IAC9D,SAAgB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjD,OAAO,CAAC,MAAM,CAAiC;IAE/C,gBAAgB;gBACG,UAAU,EAAE,4BAA4B;IAO3D,8CAA8C;IAC9C,IAAW,IAAI,IAAI,wBAAwB,CAE1C;IAED;;;OAGG;IAEI,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IA6BjC;;;OAGG;IACI,sBAAsB,CAAC,kBAAkB,EAAE,MAAM,EAAE,GAAG,IAAI;IAUjE;;;;;;OAMG;IACH,IAAW,KAAK,IAAI,MAAM,GAAG,SAAS,CAErC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;CAMhD"}
|
85
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineStringParameter.js
generated
vendored
Normal file
85
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineStringParameter.js
generated
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CommandLineStringParameter = void 0;
|
||||
const BaseClasses_1 = require("./BaseClasses");
|
||||
/**
|
||||
* The data type returned by {@link CommandLineParameterProvider.defineStringParameter}.
|
||||
* @public
|
||||
*/
|
||||
class CommandLineStringParameter extends BaseClasses_1.CommandLineParameterWithArgument {
|
||||
/** @internal */
|
||||
constructor(definition) {
|
||||
super(definition);
|
||||
this._value = undefined;
|
||||
this.defaultValue = definition.defaultValue;
|
||||
this.validateDefaultValue(!!this.defaultValue);
|
||||
}
|
||||
/** {@inheritDoc CommandLineParameter.kind} */
|
||||
get kind() {
|
||||
return BaseClasses_1.CommandLineParameterKind.String;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._setValue}
|
||||
* @internal
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
_setValue(data) {
|
||||
// abstract
|
||||
if (data !== null && data !== undefined) {
|
||||
if (typeof data !== 'string') {
|
||||
this.reportInvalidData(data);
|
||||
}
|
||||
this._value = data;
|
||||
return;
|
||||
}
|
||||
if (this.environmentVariable !== undefined) {
|
||||
// Try reading the environment variable
|
||||
const environmentValue = process.env[this.environmentVariable];
|
||||
if (environmentValue !== undefined) {
|
||||
// NOTE: If the environment variable is defined as an empty string,
|
||||
// here we will accept the empty string as our value. (For number/flag we don't do that.)
|
||||
this._value = environmentValue;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.defaultValue !== undefined) {
|
||||
this._value = this.defaultValue;
|
||||
return;
|
||||
}
|
||||
this._value = undefined;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameter._getSupplementaryNotes}
|
||||
* @internal
|
||||
*/
|
||||
_getSupplementaryNotes(supplementaryNotes) {
|
||||
// virtual
|
||||
super._getSupplementaryNotes(supplementaryNotes);
|
||||
if (this.defaultValue !== undefined) {
|
||||
if (this.defaultValue.length < 160) {
|
||||
supplementaryNotes.push(`The default value is ${JSON.stringify(this.defaultValue)}.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the argument value for a string parameter that was parsed from the command line.
|
||||
*
|
||||
* @remarks
|
||||
* The return value will be undefined if the command-line has not been parsed yet,
|
||||
* or if the parameter was omitted and has no default value.
|
||||
*/
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
||||
appendToArgList(argList) {
|
||||
if (this.value !== undefined) {
|
||||
argList.push(this.longName);
|
||||
argList.push(this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.CommandLineStringParameter = CommandLineStringParameter;
|
||||
//# sourceMappingURL=CommandLineStringParameter.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineStringParameter.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/CommandLineStringParameter.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineStringParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineStringParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA2F;AAE3F;;;GAGG;AACH,MAAa,0BAA2B,SAAQ,8CAAgC;IAM9E,gBAAgB;IAChB,YAAmB,UAAwC;QACzD,KAAK,CAAC,UAAU,CAAC,CAAC;QAJZ,WAAM,GAAuB,SAAS,CAAC;QAM7C,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;QAC5C,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjD,CAAC;IAED,8CAA8C;IAC9C,IAAW,IAAI;QACb,OAAO,sCAAwB,CAAC,MAAM,CAAC;IACzC,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,WAAW;QACX,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACvC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;gBAC5B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;aAC9B;YACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,OAAO;SACR;QAED,IAAI,IAAI,CAAC,mBAAmB,KAAK,SAAS,EAAE;YAC1C,uCAAuC;YACvC,MAAM,gBAAgB,GAAuB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACnF,IAAI,gBAAgB,KAAK,SAAS,EAAE;gBAClC,mEAAmE;gBACnE,0FAA0F;gBAC1F,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC;gBAC/B,OAAO;aACR;SACF;QAED,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;YACnC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC;YAChC,OAAO;SACR;QAED,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,sBAAsB,CAAC,kBAA4B;QACxD,UAAU;QACV,KAAK,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;YACnC,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,GAAG,EAAE;gBAClC,kBAAkB,CAAC,IAAI,CAAC,wBAAwB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;aACvF;SACF;IACH,CAAC;IAED;;;;;;OAMG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1B;IACH,CAAC;CACF;AArFD,gEAqFC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ICommandLineStringDefinition } from './CommandLineDefinition';\nimport { CommandLineParameterWithArgument, CommandLineParameterKind } from './BaseClasses';\n\n/**\n * The data type returned by {@link CommandLineParameterProvider.defineStringParameter}.\n * @public\n */\nexport class CommandLineStringParameter extends CommandLineParameterWithArgument {\n /** {@inheritDoc ICommandLineStringDefinition.defaultValue} */\n public readonly defaultValue: string | undefined;\n\n private _value: string | undefined = undefined;\n\n /** @internal */\n public constructor(definition: ICommandLineStringDefinition) {\n super(definition);\n\n this.defaultValue = definition.defaultValue;\n this.validateDefaultValue(!!this.defaultValue);\n }\n\n /** {@inheritDoc CommandLineParameter.kind} */\n public get kind(): CommandLineParameterKind {\n return CommandLineParameterKind.String;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._setValue}\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public _setValue(data: any): void {\n // abstract\n if (data !== null && data !== undefined) {\n if (typeof data !== 'string') {\n this.reportInvalidData(data);\n }\n this._value = data;\n return;\n }\n\n if (this.environmentVariable !== undefined) {\n // Try reading the environment variable\n const environmentValue: string | undefined = process.env[this.environmentVariable];\n if (environmentValue !== undefined) {\n // NOTE: If the environment variable is defined as an empty string,\n // here we will accept the empty string as our value. (For number/flag we don't do that.)\n this._value = environmentValue;\n return;\n }\n }\n\n if (this.defaultValue !== undefined) {\n this._value = this.defaultValue;\n return;\n }\n\n this._value = undefined;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._getSupplementaryNotes}\n * @internal\n */\n public _getSupplementaryNotes(supplementaryNotes: string[]): void {\n // virtual\n super._getSupplementaryNotes(supplementaryNotes);\n if (this.defaultValue !== undefined) {\n if (this.defaultValue.length < 160) {\n supplementaryNotes.push(`The default value is ${JSON.stringify(this.defaultValue)}.`);\n }\n }\n }\n\n /**\n * Returns the argument value for a string parameter that was parsed from the command line.\n *\n * @remarks\n * The return value will be undefined if the command-line has not been parsed yet,\n * or if the parameter was omitted and has no default value.\n */\n public get value(): string | undefined {\n return this._value;\n }\n\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\n public appendToArgList(argList: string[]): void {\n if (this.value !== undefined) {\n argList.push(this.longName);\n argList.push(this.value);\n }\n }\n}\n"]}
|
10
node_modules/@rushstack/ts-command-line/lib/parameters/EnvironmentVariableParser.d.ts
generated
vendored
Normal file
10
node_modules/@rushstack/ts-command-line/lib/parameters/EnvironmentVariableParser.d.ts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Some parameter types can receive their values from an environment variable instead of
|
||||
* a command line argument. This class provides some utility methods for parsing environment
|
||||
* variable values.
|
||||
* @internal
|
||||
*/
|
||||
export declare class EnvironmentVariableParser {
|
||||
static parseAsList(envVarName: string): string[] | undefined;
|
||||
}
|
||||
//# sourceMappingURL=EnvironmentVariableParser.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/EnvironmentVariableParser.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/EnvironmentVariableParser.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"EnvironmentVariableParser.d.ts","sourceRoot":"","sources":["../../src/parameters/EnvironmentVariableParser.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,qBAAa,yBAAyB;WACtB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS;CA2CpE"}
|
51
node_modules/@rushstack/ts-command-line/lib/parameters/EnvironmentVariableParser.js
generated
vendored
Normal file
51
node_modules/@rushstack/ts-command-line/lib/parameters/EnvironmentVariableParser.js
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.EnvironmentVariableParser = void 0;
|
||||
/**
|
||||
* Some parameter types can receive their values from an environment variable instead of
|
||||
* a command line argument. This class provides some utility methods for parsing environment
|
||||
* variable values.
|
||||
* @internal
|
||||
*/
|
||||
class EnvironmentVariableParser {
|
||||
static parseAsList(envVarName) {
|
||||
const environmentValue = process.env[envVarName];
|
||||
if (environmentValue !== undefined) {
|
||||
// NOTE: If the environment variable is defined as an empty string,
|
||||
// here we will accept the empty string as our value. (For number/flag we don't do that.)
|
||||
if (environmentValue.trimLeft()[0] === '[') {
|
||||
// Specifying multiple items in an environment variable is a somewhat rare case. But environment
|
||||
// variables are actually a pretty reliable way for a tool to avoid shell escaping problems
|
||||
// when spawning another tool. For this case, we need a reliable way to pass an array of strings
|
||||
// that could contain any character. For example, if we simply used ";" as the list delimiter,
|
||||
// then what to do if a string contains that character? We'd need to design an escaping mechanism.
|
||||
// Since JSON is simple and standard and can escape every possible string, it's a better option
|
||||
// than a custom delimiter.
|
||||
try {
|
||||
const parsedJson = JSON.parse(environmentValue);
|
||||
if (!Array.isArray(parsedJson) ||
|
||||
!parsedJson.every((x) => typeof x === 'string' || typeof x === 'boolean' || typeof x === 'number')) {
|
||||
throw new Error(`The ${environmentValue} environment variable value must be a JSON ` +
|
||||
` array containing only strings, numbers, and booleans.`);
|
||||
}
|
||||
return parsedJson.map((x) => x.toString());
|
||||
}
|
||||
catch (ex) {
|
||||
throw new Error(`The ${environmentValue} environment variable value looks like a JSON array` +
|
||||
` but failed to parse: ` +
|
||||
ex.message);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// As a shorthand, a single value may be specified without JSON encoding, as long as it does not
|
||||
// start with the "[" character.
|
||||
return [environmentValue];
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
exports.EnvironmentVariableParser = EnvironmentVariableParser;
|
||||
//# sourceMappingURL=EnvironmentVariableParser.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/parameters/EnvironmentVariableParser.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/parameters/EnvironmentVariableParser.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"EnvironmentVariableParser.js","sourceRoot":"","sources":["../../src/parameters/EnvironmentVariableParser.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;;;GAKG;AACH,MAAa,yBAAyB;IAC7B,MAAM,CAAC,WAAW,CAAC,UAAkB;QAC1C,MAAM,gBAAgB,GAAuB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAErE,IAAI,gBAAgB,KAAK,SAAS,EAAE;YAClC,mEAAmE;YACnE,0FAA0F;YAE1F,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;gBAC1C,iGAAiG;gBACjG,2FAA2F;gBAC3F,iGAAiG;gBACjG,+FAA+F;gBAC/F,mGAAmG;gBACnG,+FAA+F;gBAC/F,2BAA2B;gBAC3B,IAAI;oBACF,MAAM,UAAU,GAAY,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;oBACzD,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;wBAC1B,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC,EAClG;wBACA,MAAM,IAAI,KAAK,CACb,OAAO,gBAAgB,6CAA6C;4BAClE,wDAAwD,CAC3D,CAAC;qBACH;oBACD,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;iBAC5C;gBAAC,OAAO,EAAE,EAAE;oBACX,MAAM,IAAI,KAAK,CACb,OAAO,gBAAgB,qDAAqD;wBAC1E,wBAAwB;wBACvB,EAAY,CAAC,OAAO,CACxB,CAAC;iBACH;aACF;iBAAM;gBACL,gGAAgG;gBAChG,gCAAgC;gBAChC,OAAO,CAAC,gBAAgB,CAAC,CAAC;aAC3B;SACF;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA5CD,8DA4CC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * Some parameter types can receive their values from an environment variable instead of\n * a command line argument. This class provides some utility methods for parsing environment\n * variable values.\n * @internal\n */\nexport class EnvironmentVariableParser {\n public static parseAsList(envVarName: string): string[] | undefined {\n const environmentValue: string | undefined = process.env[envVarName];\n\n if (environmentValue !== undefined) {\n // NOTE: If the environment variable is defined as an empty string,\n // here we will accept the empty string as our value. (For number/flag we don't do that.)\n\n if (environmentValue.trimLeft()[0] === '[') {\n // Specifying multiple items in an environment variable is a somewhat rare case. But environment\n // variables are actually a pretty reliable way for a tool to avoid shell escaping problems\n // when spawning another tool. For this case, we need a reliable way to pass an array of strings\n // that could contain any character. For example, if we simply used \";\" as the list delimiter,\n // then what to do if a string contains that character? We'd need to design an escaping mechanism.\n // Since JSON is simple and standard and can escape every possible string, it's a better option\n // than a custom delimiter.\n try {\n const parsedJson: unknown = JSON.parse(environmentValue);\n if (\n !Array.isArray(parsedJson) ||\n !parsedJson.every((x) => typeof x === 'string' || typeof x === 'boolean' || typeof x === 'number')\n ) {\n throw new Error(\n `The ${environmentValue} environment variable value must be a JSON ` +\n ` array containing only strings, numbers, and booleans.`\n );\n }\n return parsedJson.map((x) => x.toString());\n } catch (ex) {\n throw new Error(\n `The ${environmentValue} environment variable value looks like a JSON array` +\n ` but failed to parse: ` +\n (ex as Error).message\n );\n }\n } else {\n // As a shorthand, a single value may be specified without JSON encoding, as long as it does not\n // start with the \"[\" character.\n return [environmentValue];\n }\n }\n\n return undefined;\n }\n}\n"]}
|
60
node_modules/@rushstack/ts-command-line/lib/providers/AliasCommandLineAction.d.ts
generated
vendored
Normal file
60
node_modules/@rushstack/ts-command-line/lib/providers/AliasCommandLineAction.d.ts
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
import { CommandLineAction } from './CommandLineAction';
|
||||
import type { ICommandLineParserData, IRegisterDefinedParametersState } from './CommandLineParameterProvider';
|
||||
import type { ICommandLineParserOptions } from './CommandLineParser';
|
||||
/**
|
||||
* Options for the AliasCommandLineAction constructor.
|
||||
* @public
|
||||
*/
|
||||
export interface IAliasCommandLineActionOptions {
|
||||
/**
|
||||
* The name of your tool when invoked from the command line. Used for generating help text.
|
||||
*/
|
||||
toolFilename: string;
|
||||
/**
|
||||
* The name of the alias. For example, if the tool is called "example",
|
||||
* then the "build" alias might be invoked as: "example build -q --some-other-option"
|
||||
*/
|
||||
aliasName: string;
|
||||
/**
|
||||
* A list of default parameters to pass to the target action.
|
||||
*/
|
||||
defaultParameters?: string[];
|
||||
/**
|
||||
* The action that this alias invokes.
|
||||
*/
|
||||
targetAction: CommandLineAction;
|
||||
}
|
||||
/**
|
||||
* Represents a sub-command that is part of the CommandLineParser command line.
|
||||
* The sub-command is an alias for another existing action.
|
||||
*
|
||||
* The alias name should be comprised of lower case words separated by hyphens
|
||||
* or colons. The name should include an English verb (e.g. "deploy"). Use a
|
||||
* hyphen to separate words (e.g. "upload-docs").
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare class AliasCommandLineAction extends CommandLineAction {
|
||||
/**
|
||||
* The action that this alias invokes.
|
||||
*/
|
||||
readonly targetAction: CommandLineAction;
|
||||
/**
|
||||
* A list of default arguments to pass to the target action.
|
||||
*/
|
||||
readonly defaultParameters: ReadonlyArray<string>;
|
||||
private _parameterKeyMap;
|
||||
constructor(options: IAliasCommandLineActionOptions);
|
||||
/** @internal */
|
||||
_registerDefinedParameters(state: IRegisterDefinedParametersState): void;
|
||||
/**
|
||||
* This is called internally by CommandLineParser.execute()
|
||||
* @internal
|
||||
*/
|
||||
_processParsedData(parserOptions: ICommandLineParserOptions, data: ICommandLineParserData): void;
|
||||
/**
|
||||
* Executes the target action.
|
||||
*/
|
||||
protected onExecute(): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=AliasCommandLineAction.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/AliasCommandLineAction.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/AliasCommandLineAction.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"AliasCommandLineAction.d.ts","sourceRoot":"","sources":["../../src/providers/AliasCommandLineAction.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAC9G,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAQrE;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE7B;;OAEG;IACH,YAAY,EAAE,iBAAiB,CAAC;CACjC;AAED;;;;;;;;;GASG;AACH,qBAAa,sBAAuB,SAAQ,iBAAiB;IAC3D;;OAEG;IACH,SAAgB,YAAY,EAAE,iBAAiB,CAAC;IAEhD;;OAEG;IACH,SAAgB,iBAAiB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAEzD,OAAO,CAAC,gBAAgB,CAAkC;gBAEvC,OAAO,EAAE,8BAA8B;IAoB1D,gBAAgB;IACT,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,GAAG,IAAI;IAoF/E;;;OAGG;IACI,kBAAkB,CAAC,aAAa,EAAE,yBAAyB,EAAE,IAAI,EAAE,sBAAsB,GAAG,IAAI;IAmBvG;;OAEG;cACa,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAG3C"}
|
156
node_modules/@rushstack/ts-command-line/lib/providers/AliasCommandLineAction.js
generated
vendored
Normal file
156
node_modules/@rushstack/ts-command-line/lib/providers/AliasCommandLineAction.js
generated
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AliasCommandLineAction = void 0;
|
||||
const argparse = __importStar(require("argparse"));
|
||||
const CommandLineAction_1 = require("./CommandLineAction");
|
||||
const BaseClasses_1 = require("../parameters/BaseClasses");
|
||||
/**
|
||||
* Represents a sub-command that is part of the CommandLineParser command line.
|
||||
* The sub-command is an alias for another existing action.
|
||||
*
|
||||
* The alias name should be comprised of lower case words separated by hyphens
|
||||
* or colons. The name should include an English verb (e.g. "deploy"). Use a
|
||||
* hyphen to separate words (e.g. "upload-docs").
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
class AliasCommandLineAction extends CommandLineAction_1.CommandLineAction {
|
||||
constructor(options) {
|
||||
const toolFilename = options.toolFilename;
|
||||
const targetActionName = options.targetAction.actionName;
|
||||
const defaultParametersString = (options.defaultParameters || []).join(' ');
|
||||
const summary = `An alias for "${toolFilename} ${targetActionName}${defaultParametersString ? ` ${defaultParametersString}` : ''}".`;
|
||||
super({
|
||||
actionName: options.aliasName,
|
||||
summary,
|
||||
documentation: `${summary} For more information on the aliased command, use ` +
|
||||
`"${toolFilename} ${targetActionName} --help".`
|
||||
});
|
||||
this._parameterKeyMap = new Map();
|
||||
this.targetAction = options.targetAction;
|
||||
this.defaultParameters = options.defaultParameters || [];
|
||||
}
|
||||
/** @internal */
|
||||
_registerDefinedParameters(state) {
|
||||
/* override */
|
||||
// All parameters are going to be defined by the target action. Re-use the target action parameters
|
||||
// for this action.
|
||||
for (const parameter of this.targetAction.parameters) {
|
||||
let aliasParameter;
|
||||
const nameOptions = {
|
||||
parameterLongName: parameter.longName,
|
||||
parameterShortName: parameter.shortName
|
||||
};
|
||||
switch (parameter.kind) {
|
||||
case BaseClasses_1.CommandLineParameterKind.Choice:
|
||||
const choiceParameter = parameter;
|
||||
aliasParameter = this.defineChoiceParameter(Object.assign(Object.assign(Object.assign({}, nameOptions), choiceParameter), { alternatives: [].concat(choiceParameter.alternatives) }));
|
||||
break;
|
||||
case BaseClasses_1.CommandLineParameterKind.ChoiceList:
|
||||
const choiceListParameter = parameter;
|
||||
aliasParameter = this.defineChoiceListParameter(Object.assign(Object.assign(Object.assign({}, nameOptions), choiceListParameter), { alternatives: [].concat(choiceListParameter.alternatives) }));
|
||||
break;
|
||||
case BaseClasses_1.CommandLineParameterKind.Flag:
|
||||
const flagParameter = parameter;
|
||||
aliasParameter = this.defineFlagParameter(Object.assign(Object.assign({}, nameOptions), flagParameter));
|
||||
break;
|
||||
case BaseClasses_1.CommandLineParameterKind.Integer:
|
||||
const integerParameter = parameter;
|
||||
aliasParameter = this.defineIntegerParameter(Object.assign(Object.assign({}, nameOptions), integerParameter));
|
||||
break;
|
||||
case BaseClasses_1.CommandLineParameterKind.IntegerList:
|
||||
const integerListParameter = parameter;
|
||||
aliasParameter = this.defineIntegerListParameter(Object.assign(Object.assign({}, nameOptions), integerListParameter));
|
||||
break;
|
||||
case BaseClasses_1.CommandLineParameterKind.String:
|
||||
const stringParameter = parameter;
|
||||
aliasParameter = this.defineStringParameter(Object.assign(Object.assign({}, nameOptions), stringParameter));
|
||||
break;
|
||||
case BaseClasses_1.CommandLineParameterKind.StringList:
|
||||
const stringListParameter = parameter;
|
||||
aliasParameter = this.defineStringListParameter(Object.assign(Object.assign({}, nameOptions), stringListParameter));
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unsupported parameter kind: ${parameter.kind}`);
|
||||
}
|
||||
// We know the parserKey is defined because the underlying _defineParameter method sets it,
|
||||
// and all parameters that we have access to have already been defined.
|
||||
this._parameterKeyMap.set(aliasParameter._parserKey, parameter._parserKey);
|
||||
}
|
||||
// We also need to register the remainder parameter if the target action has one. The parser
|
||||
// key for this parameter is constant.
|
||||
if (this.targetAction.remainder) {
|
||||
this.defineCommandLineRemainder(this.targetAction.remainder);
|
||||
this._parameterKeyMap.set(argparse.Const.REMAINDER, argparse.Const.REMAINDER);
|
||||
}
|
||||
// Finally, register the parameters with the parser. We need to make sure that the target action
|
||||
// is registered, since we need to re-use its parameters, and ambiguous parameters are discovered
|
||||
// during registration. This will no-op if the target action is already registered.
|
||||
this.targetAction._registerDefinedParameters(state);
|
||||
super._registerDefinedParameters(state);
|
||||
// We need to re-map the ambiguous parameters after they are defined by calling
|
||||
// super._registerDefinedParameters()
|
||||
for (const [ambiguousParameterName, parserKey] of this._ambiguousParameterParserKeysByName) {
|
||||
const targetParserKey = this.targetAction._ambiguousParameterParserKeysByName.get(ambiguousParameterName);
|
||||
// If we have a mapping for the specified key, then use it. Otherwise, use the key as-is.
|
||||
if (targetParserKey) {
|
||||
this._parameterKeyMap.set(parserKey, targetParserKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This is called internally by CommandLineParser.execute()
|
||||
* @internal
|
||||
*/
|
||||
_processParsedData(parserOptions, data) {
|
||||
// Re-map the parsed data to the target action's parameters and execute the target action processor.
|
||||
const targetData = {
|
||||
action: this.targetAction.actionName,
|
||||
aliasAction: data.action,
|
||||
aliasDocumentation: this.documentation
|
||||
};
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
// If we have a mapping for the specified key, then use it. Otherwise, use the key as-is.
|
||||
// Skip over the action key though, since we've already re-mapped it to "aliasAction"
|
||||
if (key === 'action') {
|
||||
continue;
|
||||
}
|
||||
const targetKey = this._parameterKeyMap.get(key);
|
||||
targetData[targetKey !== null && targetKey !== void 0 ? targetKey : key] = value;
|
||||
}
|
||||
this.targetAction._processParsedData(parserOptions, targetData);
|
||||
}
|
||||
/**
|
||||
* Executes the target action.
|
||||
*/
|
||||
async onExecute() {
|
||||
await this.targetAction._execute();
|
||||
}
|
||||
}
|
||||
exports.AliasCommandLineAction = AliasCommandLineAction;
|
||||
//# sourceMappingURL=AliasCommandLineAction.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/AliasCommandLineAction.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/AliasCommandLineAction.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
72
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineAction.d.ts
generated
vendored
Normal file
72
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineAction.d.ts
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
import type * as argparse from 'argparse';
|
||||
import { CommandLineParameterProvider, type ICommandLineParserData } from './CommandLineParameterProvider';
|
||||
import type { ICommandLineParserOptions } from './CommandLineParser';
|
||||
/**
|
||||
* Options for the CommandLineAction constructor.
|
||||
* @public
|
||||
*/
|
||||
export interface ICommandLineActionOptions {
|
||||
/**
|
||||
* The name of the action. For example, if the tool is called "example",
|
||||
* then the "build" action might be invoked as: "example build -q --some-other-option"
|
||||
*/
|
||||
actionName: string;
|
||||
/**
|
||||
* A quick summary that is shown on the main help page, which is displayed
|
||||
* by the command "example --help"
|
||||
*/
|
||||
summary: string;
|
||||
/**
|
||||
* A detailed description that is shown on the action help page, which is displayed
|
||||
* by the command "example build --help", e.g. for actionName="build".
|
||||
*/
|
||||
documentation: string;
|
||||
}
|
||||
/**
|
||||
* Represents a sub-command that is part of the CommandLineParser command line.
|
||||
* Applications should create subclasses of CommandLineAction corresponding to
|
||||
* each action that they want to expose.
|
||||
*
|
||||
* The action name should be comprised of lower case words separated by hyphens
|
||||
* or colons. The name should include an English verb (e.g. "deploy"). Use a
|
||||
* hyphen to separate words (e.g. "upload-docs"). A group of related commands
|
||||
* can be prefixed with a colon (e.g. "docs:generate", "docs:deploy",
|
||||
* "docs:serve", etc).
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class CommandLineAction extends CommandLineParameterProvider {
|
||||
/** {@inheritDoc ICommandLineActionOptions.actionName} */
|
||||
readonly actionName: string;
|
||||
/** {@inheritDoc ICommandLineActionOptions.summary} */
|
||||
readonly summary: string;
|
||||
/** {@inheritDoc ICommandLineActionOptions.documentation} */
|
||||
readonly documentation: string;
|
||||
private _argumentParser;
|
||||
constructor(options: ICommandLineActionOptions);
|
||||
/**
|
||||
* This is called internally by CommandLineParser.addAction()
|
||||
* @internal
|
||||
*/
|
||||
_buildParser(actionsSubParser: argparse.SubParser): void;
|
||||
/**
|
||||
* This is called internally by CommandLineParser.execute()
|
||||
* @internal
|
||||
*/
|
||||
_processParsedData(parserOptions: ICommandLineParserOptions, data: ICommandLineParserData): void;
|
||||
/**
|
||||
* Invoked by CommandLineParser.onExecute().
|
||||
* @internal
|
||||
*/
|
||||
_execute(): Promise<void>;
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameterProvider._getArgumentParser}
|
||||
* @internal
|
||||
*/
|
||||
protected _getArgumentParser(): argparse.ArgumentParser;
|
||||
/**
|
||||
* Your subclass should implement this hook to perform the operation.
|
||||
*/
|
||||
protected abstract onExecute(): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=CommandLineAction.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineAction.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineAction.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineAction.d.ts","sourceRoot":"","sources":["../../src/providers/CommandLineAction.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,QAAQ,MAAM,UAAU,CAAC;AAE1C,OAAO,EAAE,4BAA4B,EAAE,KAAK,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC3G,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAGrE;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB;AAOD;;;;;;;;;;;;GAYG;AACH,8BAAsB,iBAAkB,SAAQ,4BAA4B;IAC1E,yDAAyD;IACzD,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC,sDAAsD;IACtD,SAAgB,OAAO,EAAE,MAAM,CAAC;IAEhC,4DAA4D;IAC5D,SAAgB,aAAa,EAAE,MAAM,CAAC;IAEtC,OAAO,CAAC,eAAe,CAAsC;gBAE1C,OAAO,EAAE,yBAAyB;IAiBrD;;;OAGG;IACI,YAAY,CAAC,gBAAgB,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI;IAwB/D;;;OAGG;IACI,kBAAkB,CAAC,aAAa,EAAE,yBAAyB,EAAE,IAAI,EAAE,sBAAsB,GAAG,IAAI;IAIvG;;;OAGG;IACI,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC;;;OAGG;IACH,SAAS,CAAC,kBAAkB,IAAI,QAAQ,CAAC,cAAc;IAUvD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAC9C"}
|
89
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineAction.js
generated
vendored
Normal file
89
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineAction.js
generated
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CommandLineAction = void 0;
|
||||
const CommandLineParameterProvider_1 = require("./CommandLineParameterProvider");
|
||||
const CommandLineParserExitError_1 = require("./CommandLineParserExitError");
|
||||
/**
|
||||
* Example: "do-something"
|
||||
*/
|
||||
const ACTION_NAME_REGEXP = /^[a-z][a-z0-9]*([-:][a-z0-9]+)*$/;
|
||||
/**
|
||||
* Represents a sub-command that is part of the CommandLineParser command line.
|
||||
* Applications should create subclasses of CommandLineAction corresponding to
|
||||
* each action that they want to expose.
|
||||
*
|
||||
* The action name should be comprised of lower case words separated by hyphens
|
||||
* or colons. The name should include an English verb (e.g. "deploy"). Use a
|
||||
* hyphen to separate words (e.g. "upload-docs"). A group of related commands
|
||||
* can be prefixed with a colon (e.g. "docs:generate", "docs:deploy",
|
||||
* "docs:serve", etc).
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
class CommandLineAction extends CommandLineParameterProvider_1.CommandLineParameterProvider {
|
||||
constructor(options) {
|
||||
super();
|
||||
if (!ACTION_NAME_REGEXP.test(options.actionName)) {
|
||||
throw new Error(`Invalid action name "${options.actionName}". ` +
|
||||
`The name must be comprised of lower-case words optionally separated by hyphens or colons.`);
|
||||
}
|
||||
this.actionName = options.actionName;
|
||||
this.summary = options.summary;
|
||||
this.documentation = options.documentation;
|
||||
this._argumentParser = undefined;
|
||||
}
|
||||
/**
|
||||
* This is called internally by CommandLineParser.addAction()
|
||||
* @internal
|
||||
*/
|
||||
_buildParser(actionsSubParser) {
|
||||
var _a;
|
||||
this._argumentParser = actionsSubParser.addParser(this.actionName, {
|
||||
help: this.summary,
|
||||
description: this.documentation
|
||||
});
|
||||
// Monkey-patch the error handling for the action parser
|
||||
this._argumentParser.exit = (status, message) => {
|
||||
throw new CommandLineParserExitError_1.CommandLineParserExitError(status, message);
|
||||
};
|
||||
const originalArgumentParserErrorFn = this._argumentParser.error.bind(this._argumentParser);
|
||||
this._argumentParser.error = (err) => {
|
||||
// Ensure the ParserExitError bubbles up to the top without any special processing
|
||||
if (err instanceof CommandLineParserExitError_1.CommandLineParserExitError) {
|
||||
throw err;
|
||||
}
|
||||
originalArgumentParserErrorFn(err);
|
||||
};
|
||||
(_a = this.onDefineParameters) === null || _a === void 0 ? void 0 : _a.call(this);
|
||||
}
|
||||
/**
|
||||
* This is called internally by CommandLineParser.execute()
|
||||
* @internal
|
||||
*/
|
||||
_processParsedData(parserOptions, data) {
|
||||
super._processParsedData(parserOptions, data);
|
||||
}
|
||||
/**
|
||||
* Invoked by CommandLineParser.onExecute().
|
||||
* @internal
|
||||
*/
|
||||
_execute() {
|
||||
return this.onExecute();
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameterProvider._getArgumentParser}
|
||||
* @internal
|
||||
*/
|
||||
_getArgumentParser() {
|
||||
// override
|
||||
if (!this._argumentParser) {
|
||||
// We will improve this in the future
|
||||
throw new Error('The CommandLineAction must be added to a CommandLineParser before it can be used');
|
||||
}
|
||||
return this._argumentParser;
|
||||
}
|
||||
}
|
||||
exports.CommandLineAction = CommandLineAction;
|
||||
//# sourceMappingURL=CommandLineAction.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineAction.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineAction.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
263
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParameterProvider.d.ts
generated
vendored
Normal file
263
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParameterProvider.d.ts
generated
vendored
Normal file
@ -0,0 +1,263 @@
|
||||
import * as argparse from 'argparse';
|
||||
import type { ICommandLineChoiceDefinition, ICommandLineChoiceListDefinition, ICommandLineIntegerDefinition, ICommandLineIntegerListDefinition, ICommandLineFlagDefinition, ICommandLineStringDefinition, ICommandLineStringListDefinition, ICommandLineRemainderDefinition } from '../parameters/CommandLineDefinition';
|
||||
import type { ICommandLineParserOptions } from './CommandLineParser';
|
||||
import { type CommandLineParameter } from '../parameters/BaseClasses';
|
||||
import { CommandLineChoiceParameter } from '../parameters/CommandLineChoiceParameter';
|
||||
import { CommandLineChoiceListParameter } from '../parameters/CommandLineChoiceListParameter';
|
||||
import { CommandLineIntegerParameter } from '../parameters/CommandLineIntegerParameter';
|
||||
import { CommandLineIntegerListParameter } from '../parameters/CommandLineIntegerListParameter';
|
||||
import { CommandLineFlagParameter } from '../parameters/CommandLineFlagParameter';
|
||||
import { CommandLineStringParameter } from '../parameters/CommandLineStringParameter';
|
||||
import { CommandLineStringListParameter } from '../parameters/CommandLineStringListParameter';
|
||||
import { CommandLineRemainder } from '../parameters/CommandLineRemainder';
|
||||
/**
|
||||
* The result containing the parsed paramter long name and scope. Returned when calling
|
||||
* {@link CommandLineParameterProvider.parseScopedLongName}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface IScopedLongNameParseResult {
|
||||
/**
|
||||
* The long name parsed from the scoped long name, e.g. "--my-scope:my-parameter" -\> "--my-parameter"
|
||||
*/
|
||||
longName: string;
|
||||
/**
|
||||
* The scope parsed from the scoped long name or undefined if no scope was found,
|
||||
* e.g. "--my-scope:my-parameter" -\> "my-scope"
|
||||
*/
|
||||
scope: string | undefined;
|
||||
}
|
||||
/**
|
||||
* An object containing the state of the
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export interface IRegisterDefinedParametersState {
|
||||
/**
|
||||
* A set of all defined parameter names registered by parent {@link CommandLineParameterProvider}
|
||||
* objects.
|
||||
*/
|
||||
parentParameterNames: Set<string>;
|
||||
}
|
||||
/**
|
||||
* This is the argparse result data object
|
||||
* @internal
|
||||
*/
|
||||
export interface ICommandLineParserData {
|
||||
action: string;
|
||||
aliasAction?: string;
|
||||
aliasDocumentation?: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
/**
|
||||
* This is the common base class for CommandLineAction and CommandLineParser
|
||||
* that provides functionality for defining command-line parameters.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class CommandLineParameterProvider {
|
||||
private static _keyCounter;
|
||||
/** @internal */
|
||||
readonly _ambiguousParameterParserKeysByName: Map<string, string>;
|
||||
/** @internal */
|
||||
protected readonly _registeredParameterParserKeysByName: Map<string, string>;
|
||||
private readonly _parameters;
|
||||
private readonly _parametersByLongName;
|
||||
private readonly _parametersByShortName;
|
||||
private readonly _parameterGroupsByName;
|
||||
private _parametersHaveBeenRegistered;
|
||||
private _parametersHaveBeenProcessed;
|
||||
private _remainder;
|
||||
/** @internal */
|
||||
constructor();
|
||||
/**
|
||||
* Returns a collection of the parameters that were defined for this object.
|
||||
*/
|
||||
get parameters(): ReadonlyArray<CommandLineParameter>;
|
||||
/**
|
||||
* Informs the caller if the argparse data has been processed into parameters.
|
||||
*/
|
||||
get parametersProcessed(): boolean;
|
||||
/**
|
||||
* If {@link CommandLineParameterProvider.defineCommandLineRemainder} was called,
|
||||
* this object captures any remaining command line arguments after the recognized portion.
|
||||
*/
|
||||
get remainder(): CommandLineRemainder | undefined;
|
||||
/**
|
||||
* Defines a command-line parameter whose value must be a string from a fixed set of
|
||||
* allowable choices (similar to an enum).
|
||||
*
|
||||
* @remarks
|
||||
* Example of a choice parameter:
|
||||
* ```
|
||||
* example-tool --log-level warn
|
||||
* ```
|
||||
*/
|
||||
defineChoiceParameter(definition: ICommandLineChoiceDefinition): CommandLineChoiceParameter;
|
||||
/**
|
||||
* Returns the CommandLineChoiceParameter with the specified long name.
|
||||
* @remarks
|
||||
* This method throws an exception if the parameter is not defined.
|
||||
*/
|
||||
getChoiceParameter(parameterLongName: string, parameterScope?: string): CommandLineChoiceParameter;
|
||||
/**
|
||||
* Defines a command-line parameter whose value must be a string from a fixed set of
|
||||
* allowable choices (similar to an enum). The parameter can be specified multiple times to
|
||||
* build a list.
|
||||
*
|
||||
* @remarks
|
||||
* Example of a choice list parameter:
|
||||
* ```
|
||||
* example-tool --allow-color red --allow-color green
|
||||
* ```
|
||||
*/
|
||||
defineChoiceListParameter(definition: ICommandLineChoiceListDefinition): CommandLineChoiceListParameter;
|
||||
/**
|
||||
* Returns the CommandLineChoiceListParameter with the specified long name.
|
||||
* @remarks
|
||||
* This method throws an exception if the parameter is not defined.
|
||||
*/
|
||||
getChoiceListParameter(parameterLongName: string, parameterScope?: string): CommandLineChoiceListParameter;
|
||||
/**
|
||||
* Defines a command-line switch whose boolean value is true if the switch is provided,
|
||||
* and false otherwise.
|
||||
*
|
||||
* @remarks
|
||||
* Example usage of a flag parameter:
|
||||
* ```
|
||||
* example-tool --debug
|
||||
* ```
|
||||
*/
|
||||
defineFlagParameter(definition: ICommandLineFlagDefinition): CommandLineFlagParameter;
|
||||
/**
|
||||
* Returns the CommandLineFlagParameter with the specified long name.
|
||||
* @remarks
|
||||
* This method throws an exception if the parameter is not defined.
|
||||
*/
|
||||
getFlagParameter(parameterLongName: string, parameterScope?: string): CommandLineFlagParameter;
|
||||
/**
|
||||
* Defines a command-line parameter whose argument is an integer.
|
||||
*
|
||||
* @remarks
|
||||
* Example usage of an integer parameter:
|
||||
* ```
|
||||
* example-tool --max-attempts 5
|
||||
* ```
|
||||
*/
|
||||
defineIntegerParameter(definition: ICommandLineIntegerDefinition): CommandLineIntegerParameter;
|
||||
/**
|
||||
* Returns the CommandLineIntegerParameter with the specified long name.
|
||||
* @remarks
|
||||
* This method throws an exception if the parameter is not defined.
|
||||
*/
|
||||
getIntegerParameter(parameterLongName: string, parameterScope?: string): CommandLineIntegerParameter;
|
||||
/**
|
||||
* Defines a command-line parameter whose argument is an integer. The parameter can be specified
|
||||
* multiple times to build a list.
|
||||
*
|
||||
* @remarks
|
||||
* Example usage of an integer list parameter:
|
||||
* ```
|
||||
* example-tool --avoid 4 --avoid 13
|
||||
* ```
|
||||
*/
|
||||
defineIntegerListParameter(definition: ICommandLineIntegerListDefinition): CommandLineIntegerListParameter;
|
||||
/**
|
||||
* Returns the CommandLineIntegerParameter with the specified long name.
|
||||
* @remarks
|
||||
* This method throws an exception if the parameter is not defined.
|
||||
*/
|
||||
getIntegerListParameter(parameterLongName: string, parameterScope?: string): CommandLineIntegerListParameter;
|
||||
/**
|
||||
* Defines a command-line parameter whose argument is a single text string.
|
||||
*
|
||||
* @remarks
|
||||
* Example usage of a string parameter:
|
||||
* ```
|
||||
* example-tool --message "Hello, world!"
|
||||
* ```
|
||||
*/
|
||||
defineStringParameter(definition: ICommandLineStringDefinition): CommandLineStringParameter;
|
||||
/**
|
||||
* Returns the CommandLineStringParameter with the specified long name.
|
||||
* @remarks
|
||||
* This method throws an exception if the parameter is not defined.
|
||||
*/
|
||||
getStringParameter(parameterLongName: string, parameterScope?: string): CommandLineStringParameter;
|
||||
/**
|
||||
* Defines a command-line parameter whose argument is a single text string. The parameter can be
|
||||
* specified multiple times to build a list.
|
||||
*
|
||||
* @remarks
|
||||
* Example usage of a string list parameter:
|
||||
* ```
|
||||
* example-tool --add file1.txt --add file2.txt --add file3.txt
|
||||
* ```
|
||||
*/
|
||||
defineStringListParameter(definition: ICommandLineStringListDefinition): CommandLineStringListParameter;
|
||||
/**
|
||||
* Defines a rule that captures any remaining command line arguments after the recognized portion.
|
||||
*
|
||||
* @remarks
|
||||
* This feature is useful for commands that pass their arguments along to an external tool, relying on
|
||||
* that tool to perform validation. (It could also be used to parse parameters without any validation
|
||||
* or documentation, but that is not recommended.)
|
||||
*
|
||||
* Example of capturing the remainder after an optional flag parameter.
|
||||
* ```
|
||||
* example-tool --my-flag this is the remainder
|
||||
* ```
|
||||
*
|
||||
* In the "--help" documentation, the remainder rule will be represented as "...".
|
||||
*/
|
||||
defineCommandLineRemainder(definition: ICommandLineRemainderDefinition): CommandLineRemainder;
|
||||
/**
|
||||
* Returns the CommandLineStringListParameter with the specified long name.
|
||||
* @remarks
|
||||
* This method throws an exception if the parameter is not defined.
|
||||
*/
|
||||
getStringListParameter(parameterLongName: string, parameterScope?: string): CommandLineStringListParameter;
|
||||
/**
|
||||
* Generates the command-line help text.
|
||||
*/
|
||||
renderHelpText(): string;
|
||||
/**
|
||||
* Generates the command-line usage text.
|
||||
*/
|
||||
renderUsageText(): string;
|
||||
/**
|
||||
* Returns a object which maps the long name of each parameter in this.parameters
|
||||
* to the stringified form of its value. This is useful for logging telemetry, but
|
||||
* it is not the proper way of accessing parameters or their values.
|
||||
*/
|
||||
getParameterStringMap(): Record<string, string>;
|
||||
/**
|
||||
* Returns an object with the parsed scope (if present) and the long name of the parameter.
|
||||
*/
|
||||
parseScopedLongName(scopedLongName: string): IScopedLongNameParseResult;
|
||||
/** @internal */
|
||||
_registerDefinedParameters(state: IRegisterDefinedParametersState): void;
|
||||
/**
|
||||
* The child class should implement this hook to define its command-line parameters,
|
||||
* e.g. by calling defineFlagParameter().
|
||||
*/
|
||||
protected onDefineParameters?(): void;
|
||||
/**
|
||||
* Retrieves the argparse object.
|
||||
* @internal
|
||||
*/
|
||||
protected abstract _getArgumentParser(): argparse.ArgumentParser;
|
||||
/** @internal */
|
||||
protected _processParsedData(parserOptions: ICommandLineParserOptions, data: ICommandLineParserData): void;
|
||||
/** @internal */
|
||||
protected _defineParameter(parameter: CommandLineParameter): void;
|
||||
/** @internal */
|
||||
protected _defineAmbiguousParameter(name: string): string;
|
||||
/** @internal */
|
||||
protected _registerParameter(parameter: CommandLineParameter, useScopedLongName: boolean, ignoreShortName: boolean): void;
|
||||
protected _registerAmbiguousParameter(name: string, parserKey: string): void;
|
||||
private _generateKey;
|
||||
private _getParameter;
|
||||
private _throwParserExitError;
|
||||
}
|
||||
//# sourceMappingURL=CommandLineParameterProvider.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParameterProvider.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParameterProvider.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineParameterProvider.d.ts","sourceRoot":"","sources":["../../src/providers/CommandLineParameterProvider.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC,OAAO,KAAK,EACV,4BAA4B,EAC5B,gCAAgC,EAChC,6BAA6B,EAC7B,iCAAiC,EACjC,0BAA0B,EAC1B,4BAA4B,EAC5B,gCAAgC,EAChC,+BAA+B,EAChC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACL,KAAK,oBAAoB,EAG1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,EAAE,8BAA8B,EAAE,MAAM,8CAA8C,CAAC;AAC9F,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AACxF,OAAO,EAAE,+BAA+B,EAAE,MAAM,+CAA+C,CAAC;AAChG,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,EAAE,8BAA8B,EAAE,MAAM,8CAA8C,CAAC;AAC9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAI1E;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;;OAGG;IACH,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACnC;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAOD;;;;;GAKG;AACH,8BAAsB,4BAA4B;IAChD,OAAO,CAAC,MAAM,CAAC,WAAW,CAAa;IAEvC,gBAAgB;IAChB,SAAgB,mCAAmC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzE,gBAAgB;IAChB,SAAS,CAAC,QAAQ,CAAC,oCAAoC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE7E,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyB;IACrD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAsC;IAC5E,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAsC;IAC7E,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAGrC;IACF,OAAO,CAAC,6BAA6B,CAAU;IAC/C,OAAO,CAAC,4BAA4B,CAAU;IAC9C,OAAO,CAAC,UAAU,CAAmC;IAErD,gBAAgB;;IAahB;;OAEG;IACH,IAAW,UAAU,IAAI,aAAa,CAAC,oBAAoB,CAAC,CAE3D;IAED;;OAEG;IACH,IAAW,mBAAmB,IAAI,OAAO,CAExC;IAED;;;OAGG;IACH,IAAW,SAAS,IAAI,oBAAoB,GAAG,SAAS,CAEvD;IAED;;;;;;;;;OASG;IACI,qBAAqB,CAAC,UAAU,EAAE,4BAA4B,GAAG,0BAA0B;IAMlG;;;;OAIG;IACI,kBAAkB,CAAC,iBAAiB,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,0BAA0B;IAIzG;;;;;;;;;;OAUG;IACI,yBAAyB,CAC9B,UAAU,EAAE,gCAAgC,GAC3C,8BAA8B;IAMjC;;;;OAIG;IACI,sBAAsB,CAC3B,iBAAiB,EAAE,MAAM,EACzB,cAAc,CAAC,EAAE,MAAM,GACtB,8BAA8B;IAIjC;;;;;;;;;OASG;IACI,mBAAmB,CAAC,UAAU,EAAE,0BAA0B,GAAG,wBAAwB;IAM5F;;;;OAIG;IACI,gBAAgB,CAAC,iBAAiB,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,wBAAwB;IAIrG;;;;;;;;OAQG;IACI,sBAAsB,CAAC,UAAU,EAAE,6BAA6B,GAAG,2BAA2B;IAMrG;;;;OAIG;IACI,mBAAmB,CACxB,iBAAiB,EAAE,MAAM,EACzB,cAAc,CAAC,EAAE,MAAM,GACtB,2BAA2B;IAI9B;;;;;;;;;OASG;IACI,0BAA0B,CAC/B,UAAU,EAAE,iCAAiC,GAC5C,+BAA+B;IAMlC;;;;OAIG;IACI,uBAAuB,CAC5B,iBAAiB,EAAE,MAAM,EACzB,cAAc,CAAC,EAAE,MAAM,GACtB,+BAA+B;IAIlC;;;;;;;;OAQG;IACI,qBAAqB,CAAC,UAAU,EAAE,4BAA4B,GAAG,0BAA0B;IAMlG;;;;OAIG;IACI,kBAAkB,CAAC,iBAAiB,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,0BAA0B;IAIzG;;;;;;;;;OASG;IACI,yBAAyB,CAC9B,UAAU,EAAE,gCAAgC,GAC3C,8BAA8B;IAMjC;;;;;;;;;;;;;;OAcG;IACI,0BAA0B,CAAC,UAAU,EAAE,+BAA+B,GAAG,oBAAoB;IAQpG;;;;OAIG;IACI,sBAAsB,CAC3B,iBAAiB,EAAE,MAAM,EACzB,cAAc,CAAC,EAAE,MAAM,GACtB,8BAA8B;IAIjC;;OAEG;IACI,cAAc,IAAI,MAAM;IAQ/B;;OAEG;IACI,eAAe,IAAI,MAAM;IAQhC;;;;OAIG;IACI,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAmCtD;;OAEG;IACI,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,0BAA0B;IAW9E,gBAAgB;IACT,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,GAAG,IAAI;IAyE/E;;;OAGG;IACH,SAAS,CAAC,kBAAkB,CAAC,IAAI,IAAI;IAErC;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,kBAAkB,IAAI,QAAQ,CAAC,cAAc;IAEhE,gBAAgB;IAChB,SAAS,CAAC,kBAAkB,CAAC,aAAa,EAAE,yBAAyB,EAAE,IAAI,EAAE,sBAAsB,GAAG,IAAI;IA0G1G,gBAAgB;IAChB,SAAS,CAAC,gBAAgB,CAAC,SAAS,EAAE,oBAAoB,GAAG,IAAI;IAiCjE,gBAAgB;IAChB,SAAS,CAAC,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAkBzD,gBAAgB;IAChB,SAAS,CAAC,kBAAkB,CAC1B,SAAS,EAAE,oBAAoB,EAC/B,iBAAiB,EAAE,OAAO,EAC1B,eAAe,EAAE,OAAO,GACvB,IAAI;IAwGP,SAAS,CAAC,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAW5E,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,aAAa;IAwCrB,OAAO,CAAC,qBAAqB;CAiB9B"}
|
647
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParameterProvider.js
generated
vendored
Normal file
647
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParameterProvider.js
generated
vendored
Normal file
@ -0,0 +1,647 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CommandLineParameterProvider = void 0;
|
||||
const argparse = __importStar(require("argparse"));
|
||||
const BaseClasses_1 = require("../parameters/BaseClasses");
|
||||
const CommandLineChoiceParameter_1 = require("../parameters/CommandLineChoiceParameter");
|
||||
const CommandLineChoiceListParameter_1 = require("../parameters/CommandLineChoiceListParameter");
|
||||
const CommandLineIntegerParameter_1 = require("../parameters/CommandLineIntegerParameter");
|
||||
const CommandLineIntegerListParameter_1 = require("../parameters/CommandLineIntegerListParameter");
|
||||
const CommandLineFlagParameter_1 = require("../parameters/CommandLineFlagParameter");
|
||||
const CommandLineStringParameter_1 = require("../parameters/CommandLineStringParameter");
|
||||
const CommandLineStringListParameter_1 = require("../parameters/CommandLineStringListParameter");
|
||||
const CommandLineRemainder_1 = require("../parameters/CommandLineRemainder");
|
||||
const Constants_1 = require("../Constants");
|
||||
const CommandLineParserExitError_1 = require("./CommandLineParserExitError");
|
||||
const SCOPE_GROUP_NAME = 'scope';
|
||||
const LONG_NAME_GROUP_NAME = 'longName';
|
||||
const POSSIBLY_SCOPED_LONG_NAME_REGEXP = /^--((?<scope>[a-z0-9]+(-[a-z0-9]+)*):)?(?<longName>[a-z0-9]+((-[a-z0-9]+)+)?)$/;
|
||||
/**
|
||||
* This is the common base class for CommandLineAction and CommandLineParser
|
||||
* that provides functionality for defining command-line parameters.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
class CommandLineParameterProvider {
|
||||
/** @internal */
|
||||
// Third party code should not inherit subclasses or call this constructor
|
||||
constructor() {
|
||||
this._parameters = [];
|
||||
this._parametersByLongName = new Map();
|
||||
this._parametersByShortName = new Map();
|
||||
this._parameterGroupsByName = new Map();
|
||||
this._ambiguousParameterParserKeysByName = new Map();
|
||||
this._registeredParameterParserKeysByName = new Map();
|
||||
this._parametersHaveBeenRegistered = false;
|
||||
this._parametersHaveBeenProcessed = false;
|
||||
}
|
||||
/**
|
||||
* Returns a collection of the parameters that were defined for this object.
|
||||
*/
|
||||
get parameters() {
|
||||
return this._parameters;
|
||||
}
|
||||
/**
|
||||
* Informs the caller if the argparse data has been processed into parameters.
|
||||
*/
|
||||
get parametersProcessed() {
|
||||
return this._parametersHaveBeenProcessed;
|
||||
}
|
||||
/**
|
||||
* If {@link CommandLineParameterProvider.defineCommandLineRemainder} was called,
|
||||
* this object captures any remaining command line arguments after the recognized portion.
|
||||
*/
|
||||
get remainder() {
|
||||
return this._remainder;
|
||||
}
|
||||
/**
|
||||
* Defines a command-line parameter whose value must be a string from a fixed set of
|
||||
* allowable choices (similar to an enum).
|
||||
*
|
||||
* @remarks
|
||||
* Example of a choice parameter:
|
||||
* ```
|
||||
* example-tool --log-level warn
|
||||
* ```
|
||||
*/
|
||||
defineChoiceParameter(definition) {
|
||||
const parameter = new CommandLineChoiceParameter_1.CommandLineChoiceParameter(definition);
|
||||
this._defineParameter(parameter);
|
||||
return parameter;
|
||||
}
|
||||
/**
|
||||
* Returns the CommandLineChoiceParameter with the specified long name.
|
||||
* @remarks
|
||||
* This method throws an exception if the parameter is not defined.
|
||||
*/
|
||||
getChoiceParameter(parameterLongName, parameterScope) {
|
||||
return this._getParameter(parameterLongName, BaseClasses_1.CommandLineParameterKind.Choice, parameterScope);
|
||||
}
|
||||
/**
|
||||
* Defines a command-line parameter whose value must be a string from a fixed set of
|
||||
* allowable choices (similar to an enum). The parameter can be specified multiple times to
|
||||
* build a list.
|
||||
*
|
||||
* @remarks
|
||||
* Example of a choice list parameter:
|
||||
* ```
|
||||
* example-tool --allow-color red --allow-color green
|
||||
* ```
|
||||
*/
|
||||
defineChoiceListParameter(definition) {
|
||||
const parameter = new CommandLineChoiceListParameter_1.CommandLineChoiceListParameter(definition);
|
||||
this._defineParameter(parameter);
|
||||
return parameter;
|
||||
}
|
||||
/**
|
||||
* Returns the CommandLineChoiceListParameter with the specified long name.
|
||||
* @remarks
|
||||
* This method throws an exception if the parameter is not defined.
|
||||
*/
|
||||
getChoiceListParameter(parameterLongName, parameterScope) {
|
||||
return this._getParameter(parameterLongName, BaseClasses_1.CommandLineParameterKind.ChoiceList, parameterScope);
|
||||
}
|
||||
/**
|
||||
* Defines a command-line switch whose boolean value is true if the switch is provided,
|
||||
* and false otherwise.
|
||||
*
|
||||
* @remarks
|
||||
* Example usage of a flag parameter:
|
||||
* ```
|
||||
* example-tool --debug
|
||||
* ```
|
||||
*/
|
||||
defineFlagParameter(definition) {
|
||||
const parameter = new CommandLineFlagParameter_1.CommandLineFlagParameter(definition);
|
||||
this._defineParameter(parameter);
|
||||
return parameter;
|
||||
}
|
||||
/**
|
||||
* Returns the CommandLineFlagParameter with the specified long name.
|
||||
* @remarks
|
||||
* This method throws an exception if the parameter is not defined.
|
||||
*/
|
||||
getFlagParameter(parameterLongName, parameterScope) {
|
||||
return this._getParameter(parameterLongName, BaseClasses_1.CommandLineParameterKind.Flag, parameterScope);
|
||||
}
|
||||
/**
|
||||
* Defines a command-line parameter whose argument is an integer.
|
||||
*
|
||||
* @remarks
|
||||
* Example usage of an integer parameter:
|
||||
* ```
|
||||
* example-tool --max-attempts 5
|
||||
* ```
|
||||
*/
|
||||
defineIntegerParameter(definition) {
|
||||
const parameter = new CommandLineIntegerParameter_1.CommandLineIntegerParameter(definition);
|
||||
this._defineParameter(parameter);
|
||||
return parameter;
|
||||
}
|
||||
/**
|
||||
* Returns the CommandLineIntegerParameter with the specified long name.
|
||||
* @remarks
|
||||
* This method throws an exception if the parameter is not defined.
|
||||
*/
|
||||
getIntegerParameter(parameterLongName, parameterScope) {
|
||||
return this._getParameter(parameterLongName, BaseClasses_1.CommandLineParameterKind.Integer, parameterScope);
|
||||
}
|
||||
/**
|
||||
* Defines a command-line parameter whose argument is an integer. The parameter can be specified
|
||||
* multiple times to build a list.
|
||||
*
|
||||
* @remarks
|
||||
* Example usage of an integer list parameter:
|
||||
* ```
|
||||
* example-tool --avoid 4 --avoid 13
|
||||
* ```
|
||||
*/
|
||||
defineIntegerListParameter(definition) {
|
||||
const parameter = new CommandLineIntegerListParameter_1.CommandLineIntegerListParameter(definition);
|
||||
this._defineParameter(parameter);
|
||||
return parameter;
|
||||
}
|
||||
/**
|
||||
* Returns the CommandLineIntegerParameter with the specified long name.
|
||||
* @remarks
|
||||
* This method throws an exception if the parameter is not defined.
|
||||
*/
|
||||
getIntegerListParameter(parameterLongName, parameterScope) {
|
||||
return this._getParameter(parameterLongName, BaseClasses_1.CommandLineParameterKind.IntegerList, parameterScope);
|
||||
}
|
||||
/**
|
||||
* Defines a command-line parameter whose argument is a single text string.
|
||||
*
|
||||
* @remarks
|
||||
* Example usage of a string parameter:
|
||||
* ```
|
||||
* example-tool --message "Hello, world!"
|
||||
* ```
|
||||
*/
|
||||
defineStringParameter(definition) {
|
||||
const parameter = new CommandLineStringParameter_1.CommandLineStringParameter(definition);
|
||||
this._defineParameter(parameter);
|
||||
return parameter;
|
||||
}
|
||||
/**
|
||||
* Returns the CommandLineStringParameter with the specified long name.
|
||||
* @remarks
|
||||
* This method throws an exception if the parameter is not defined.
|
||||
*/
|
||||
getStringParameter(parameterLongName, parameterScope) {
|
||||
return this._getParameter(parameterLongName, BaseClasses_1.CommandLineParameterKind.String, parameterScope);
|
||||
}
|
||||
/**
|
||||
* Defines a command-line parameter whose argument is a single text string. The parameter can be
|
||||
* specified multiple times to build a list.
|
||||
*
|
||||
* @remarks
|
||||
* Example usage of a string list parameter:
|
||||
* ```
|
||||
* example-tool --add file1.txt --add file2.txt --add file3.txt
|
||||
* ```
|
||||
*/
|
||||
defineStringListParameter(definition) {
|
||||
const parameter = new CommandLineStringListParameter_1.CommandLineStringListParameter(definition);
|
||||
this._defineParameter(parameter);
|
||||
return parameter;
|
||||
}
|
||||
/**
|
||||
* Defines a rule that captures any remaining command line arguments after the recognized portion.
|
||||
*
|
||||
* @remarks
|
||||
* This feature is useful for commands that pass their arguments along to an external tool, relying on
|
||||
* that tool to perform validation. (It could also be used to parse parameters without any validation
|
||||
* or documentation, but that is not recommended.)
|
||||
*
|
||||
* Example of capturing the remainder after an optional flag parameter.
|
||||
* ```
|
||||
* example-tool --my-flag this is the remainder
|
||||
* ```
|
||||
*
|
||||
* In the "--help" documentation, the remainder rule will be represented as "...".
|
||||
*/
|
||||
defineCommandLineRemainder(definition) {
|
||||
if (this._remainder) {
|
||||
throw new Error('defineRemainingArguments() has already been called for this provider');
|
||||
}
|
||||
this._remainder = new CommandLineRemainder_1.CommandLineRemainder(definition);
|
||||
return this._remainder;
|
||||
}
|
||||
/**
|
||||
* Returns the CommandLineStringListParameter with the specified long name.
|
||||
* @remarks
|
||||
* This method throws an exception if the parameter is not defined.
|
||||
*/
|
||||
getStringListParameter(parameterLongName, parameterScope) {
|
||||
return this._getParameter(parameterLongName, BaseClasses_1.CommandLineParameterKind.StringList, parameterScope);
|
||||
}
|
||||
/**
|
||||
* Generates the command-line help text.
|
||||
*/
|
||||
renderHelpText() {
|
||||
const initialState = {
|
||||
parentParameterNames: new Set()
|
||||
};
|
||||
this._registerDefinedParameters(initialState);
|
||||
return this._getArgumentParser().formatHelp();
|
||||
}
|
||||
/**
|
||||
* Generates the command-line usage text.
|
||||
*/
|
||||
renderUsageText() {
|
||||
const initialState = {
|
||||
parentParameterNames: new Set()
|
||||
};
|
||||
this._registerDefinedParameters(initialState);
|
||||
return this._getArgumentParser().formatUsage();
|
||||
}
|
||||
/**
|
||||
* Returns a object which maps the long name of each parameter in this.parameters
|
||||
* to the stringified form of its value. This is useful for logging telemetry, but
|
||||
* it is not the proper way of accessing parameters or their values.
|
||||
*/
|
||||
getParameterStringMap() {
|
||||
const parameterMap = {};
|
||||
for (const parameter of this.parameters) {
|
||||
const parameterName = parameter.scopedLongName || parameter.longName;
|
||||
switch (parameter.kind) {
|
||||
case BaseClasses_1.CommandLineParameterKind.Flag:
|
||||
case BaseClasses_1.CommandLineParameterKind.Choice:
|
||||
case BaseClasses_1.CommandLineParameterKind.String:
|
||||
case BaseClasses_1.CommandLineParameterKind.Integer:
|
||||
parameterMap[parameterName] = JSON.stringify(parameter.value);
|
||||
break;
|
||||
case BaseClasses_1.CommandLineParameterKind.StringList:
|
||||
case BaseClasses_1.CommandLineParameterKind.IntegerList:
|
||||
case BaseClasses_1.CommandLineParameterKind.ChoiceList:
|
||||
const arrayValue = parameter.values;
|
||||
parameterMap[parameterName] = arrayValue ? arrayValue.join(',') : '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return parameterMap;
|
||||
}
|
||||
/**
|
||||
* Returns an object with the parsed scope (if present) and the long name of the parameter.
|
||||
*/
|
||||
parseScopedLongName(scopedLongName) {
|
||||
const result = POSSIBLY_SCOPED_LONG_NAME_REGEXP.exec(scopedLongName);
|
||||
if (!result || !result.groups) {
|
||||
throw new Error(`The parameter long name "${scopedLongName}" is not valid.`);
|
||||
}
|
||||
return {
|
||||
longName: `--${result.groups[LONG_NAME_GROUP_NAME]}`,
|
||||
scope: result.groups[SCOPE_GROUP_NAME]
|
||||
};
|
||||
}
|
||||
/** @internal */
|
||||
_registerDefinedParameters(state) {
|
||||
if (this._parametersHaveBeenRegistered) {
|
||||
// We prevent new parameters from being defined after the first call to _registerDefinedParameters,
|
||||
// so we can already ensure that all parameters were registered.
|
||||
return;
|
||||
}
|
||||
// First, loop through all parameters with short names. If there are any duplicates, disable the short names
|
||||
// since we can't prefix scopes to short names in order to deduplicate them. The duplicate short names will
|
||||
// be reported as errors if the user attempts to use them.
|
||||
const parametersWithDuplicateShortNames = new Set();
|
||||
for (const [shortName, shortNameParameters] of this._parametersByShortName.entries()) {
|
||||
if (shortNameParameters.length > 1) {
|
||||
for (const parameter of shortNameParameters) {
|
||||
this._defineAmbiguousParameter(shortName);
|
||||
parametersWithDuplicateShortNames.add(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Then, loop through all parameters and register them. If there are any duplicates, ensure that they have
|
||||
// provided a scope and register them with the scope. The duplicate long names will be reported as an error
|
||||
// if the user attempts to use them.
|
||||
for (const longNameParameters of this._parametersByLongName.values()) {
|
||||
const useScopedLongName = longNameParameters.length > 1;
|
||||
for (const parameter of longNameParameters) {
|
||||
if (useScopedLongName) {
|
||||
if (!parameter.parameterScope) {
|
||||
throw new Error(`The parameter "${parameter.longName}" is defined multiple times with the same long name. ` +
|
||||
'Parameters with the same long name must define a scope.');
|
||||
}
|
||||
this._defineAmbiguousParameter(parameter.longName);
|
||||
}
|
||||
const ignoreShortName = parametersWithDuplicateShortNames.has(parameter);
|
||||
this._registerParameter(parameter, useScopedLongName, ignoreShortName);
|
||||
}
|
||||
}
|
||||
// Register the existing parameters as ambiguous parameters. These are generally provided by the
|
||||
// parent action.
|
||||
const { parentParameterNames } = state;
|
||||
for (const parentParameterName of parentParameterNames) {
|
||||
this._defineAmbiguousParameter(parentParameterName);
|
||||
}
|
||||
// We also need to loop through the defined ambiguous parameters and register them. These will be reported
|
||||
// as errors if the user attempts to use them.
|
||||
for (const [ambiguousParameterName, parserKey] of this._ambiguousParameterParserKeysByName) {
|
||||
// Only register the ambiguous parameter if it hasn't already been registered. We will still handle these
|
||||
// already-registered parameters as ambiguous, but by avoiding registering again, we will defer errors
|
||||
// until the user actually attempts to use the parameter.
|
||||
if (!this._registeredParameterParserKeysByName.has(ambiguousParameterName)) {
|
||||
this._registerAmbiguousParameter(ambiguousParameterName, parserKey);
|
||||
}
|
||||
}
|
||||
// Need to add the remainder parameter last
|
||||
if (this._remainder) {
|
||||
const argparseOptions = {
|
||||
help: this._remainder.description,
|
||||
nargs: argparse.Const.REMAINDER,
|
||||
metavar: '"..."'
|
||||
};
|
||||
this._getArgumentParser().addArgument(argparse.Const.REMAINDER, argparseOptions);
|
||||
}
|
||||
this._parametersHaveBeenRegistered = true;
|
||||
}
|
||||
/** @internal */
|
||||
_processParsedData(parserOptions, data) {
|
||||
if (!this._parametersHaveBeenRegistered) {
|
||||
throw new Error('Parameters have not been registered');
|
||||
}
|
||||
if (this._parametersHaveBeenProcessed) {
|
||||
throw new Error('Command Line Parser Data was already processed');
|
||||
}
|
||||
// Search for any ambiguous parameters and throw an error if any are found
|
||||
for (const [parameterName, parserKey] of this._ambiguousParameterParserKeysByName) {
|
||||
if (data[parserKey]) {
|
||||
// When the parser key matches the actually registered parameter, we know that this is an ambiguous
|
||||
// parameter sourced from the parent action or tool
|
||||
if (this._registeredParameterParserKeysByName.get(parameterName) === parserKey) {
|
||||
this._throwParserExitError(parserOptions, data, 1, `Ambiguous option: "${parameterName}".`);
|
||||
}
|
||||
// Determine if the ambiguous parameter is a short name or a long name, since the process of finding
|
||||
// the non-ambiguous name is different for each.
|
||||
const duplicateShortNameParameters = this._parametersByShortName.get(parameterName);
|
||||
if (duplicateShortNameParameters) {
|
||||
// We also need to make sure we get the non-ambiguous long name for the parameter, since it is
|
||||
// possible for that the long name is ambiguous as well.
|
||||
const nonAmbiguousLongNames = [];
|
||||
for (const parameter of duplicateShortNameParameters) {
|
||||
const matchingLongNameParameters = this._parametersByLongName.get(parameter.longName);
|
||||
if (!(matchingLongNameParameters === null || matchingLongNameParameters === void 0 ? void 0 : matchingLongNameParameters.length)) {
|
||||
// This should never happen
|
||||
throw new Error(`Unable to find long name parameters for ambiguous short name parameter "${parameterName}".`);
|
||||
}
|
||||
// If there is more than one matching long name parameter, then we know that we need to use the
|
||||
// scoped long name for the parameter. The scoped long name should always be provided.
|
||||
if (matchingLongNameParameters.length > 1) {
|
||||
if (!parameter.scopedLongName) {
|
||||
// This should never happen
|
||||
throw new Error(`Unable to find scoped long name for ambiguous short name parameter "${parameterName}".`);
|
||||
}
|
||||
nonAmbiguousLongNames.push(parameter.scopedLongName);
|
||||
}
|
||||
else {
|
||||
nonAmbiguousLongNames.push(parameter.longName);
|
||||
}
|
||||
}
|
||||
// Throw an error including the non-ambiguous long names for the parameters that have the ambiguous
|
||||
// short name, ex.
|
||||
// Error: Ambiguous option "-p" could match "--param1", "--param2"
|
||||
this._throwParserExitError(parserOptions, data, 1, `Ambiguous option: "${parameterName}" could match ${nonAmbiguousLongNames.join(', ')}.`);
|
||||
}
|
||||
const duplicateLongNameParameters = this._parametersByLongName.get(parameterName);
|
||||
if (duplicateLongNameParameters) {
|
||||
const nonAmbiguousLongNames = duplicateLongNameParameters.map((p) => {
|
||||
// The scoped long name should always be provided
|
||||
if (!p.scopedLongName) {
|
||||
// This should never happen
|
||||
throw new Error(`Unable to find scoped long name for ambiguous long name parameter "${parameterName}".`);
|
||||
}
|
||||
return p.scopedLongName;
|
||||
});
|
||||
// Throw an error including the non-ambiguous scoped long names for the parameters that have the
|
||||
// ambiguous long name, ex.
|
||||
// Error: Ambiguous option: "--param" could match --scope1:param, --scope2:param
|
||||
this._throwParserExitError(parserOptions, data, 1, `Ambiguous option: "${parameterName}" could match ${nonAmbiguousLongNames.join(', ')}.`);
|
||||
}
|
||||
// This shouldn't happen, but we also shouldn't allow the user to use the ambiguous parameter
|
||||
this._throwParserExitError(parserOptions, data, 1, `Ambiguous option: "${parameterName}".`);
|
||||
}
|
||||
}
|
||||
// Fill in the values for the parameters
|
||||
for (const parameter of this._parameters) {
|
||||
const value = data[parameter._parserKey]; // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
parameter._setValue(value);
|
||||
}
|
||||
if (this.remainder) {
|
||||
this.remainder._setValue(data[argparse.Const.REMAINDER]);
|
||||
}
|
||||
this._parametersHaveBeenProcessed = true;
|
||||
}
|
||||
/** @internal */
|
||||
_defineParameter(parameter) {
|
||||
if (this._parametersHaveBeenRegistered) {
|
||||
throw new Error('Parameters have already been registered for this provider');
|
||||
}
|
||||
// Generate and set the parser key at definition time
|
||||
parameter._parserKey = this._generateKey();
|
||||
this._parameters.push(parameter);
|
||||
// Collect all parameters with the same long name. We will perform conflict resolution at registration.
|
||||
let longNameParameters = this._parametersByLongName.get(parameter.longName);
|
||||
if (!longNameParameters) {
|
||||
longNameParameters = [];
|
||||
this._parametersByLongName.set(parameter.longName, longNameParameters);
|
||||
}
|
||||
longNameParameters.push(parameter);
|
||||
// Collect all parameters with the same short name. We will perform conflict resolution at registration.
|
||||
if (parameter.shortName) {
|
||||
let shortNameParameters = this._parametersByShortName.get(parameter.shortName);
|
||||
if (!shortNameParameters) {
|
||||
shortNameParameters = [];
|
||||
this._parametersByShortName.set(parameter.shortName, shortNameParameters);
|
||||
}
|
||||
shortNameParameters.push(parameter);
|
||||
}
|
||||
}
|
||||
/** @internal */
|
||||
_defineAmbiguousParameter(name) {
|
||||
if (this._parametersHaveBeenRegistered) {
|
||||
throw new Error('Parameters have already been registered for this provider');
|
||||
}
|
||||
// Only generate a new parser key if the ambiguous parameter hasn't been defined yet,
|
||||
// either as an existing parameter or as another ambiguous parameter
|
||||
let existingParserKey = this._registeredParameterParserKeysByName.get(name) ||
|
||||
this._ambiguousParameterParserKeysByName.get(name);
|
||||
if (!existingParserKey) {
|
||||
existingParserKey = this._generateKey();
|
||||
}
|
||||
this._ambiguousParameterParserKeysByName.set(name, existingParserKey);
|
||||
return existingParserKey;
|
||||
}
|
||||
/** @internal */
|
||||
_registerParameter(parameter, useScopedLongName, ignoreShortName) {
|
||||
var _a;
|
||||
const names = [];
|
||||
if (parameter.shortName && !ignoreShortName) {
|
||||
names.push(parameter.shortName);
|
||||
}
|
||||
// Use the original long name unless otherwise requested
|
||||
if (!useScopedLongName) {
|
||||
names.push(parameter.longName);
|
||||
}
|
||||
// Add the scoped long name if it exists
|
||||
if (parameter.scopedLongName) {
|
||||
names.push(parameter.scopedLongName);
|
||||
}
|
||||
let finalDescription = parameter.description;
|
||||
const supplementaryNotes = [];
|
||||
parameter._getSupplementaryNotes(supplementaryNotes);
|
||||
if (supplementaryNotes.length > 0) {
|
||||
// If they left the period off the end of their sentence, then add one.
|
||||
if (finalDescription.match(/[a-z0-9]"?\s*$/i)) {
|
||||
finalDescription = finalDescription.trimRight() + '.';
|
||||
}
|
||||
// Append the supplementary text
|
||||
finalDescription += ' ' + supplementaryNotes.join(' ');
|
||||
}
|
||||
// NOTE: Our "environmentVariable" feature takes precedence over argparse's "defaultValue",
|
||||
// so we have to reimplement that feature.
|
||||
const argparseOptions = {
|
||||
help: finalDescription,
|
||||
dest: parameter._parserKey,
|
||||
metavar: parameter.argumentName || undefined,
|
||||
required: parameter.required
|
||||
};
|
||||
switch (parameter.kind) {
|
||||
case BaseClasses_1.CommandLineParameterKind.Choice: {
|
||||
const choiceParameter = parameter;
|
||||
argparseOptions.choices = choiceParameter.alternatives;
|
||||
break;
|
||||
}
|
||||
case BaseClasses_1.CommandLineParameterKind.ChoiceList: {
|
||||
const choiceParameter = parameter;
|
||||
argparseOptions.choices = choiceParameter.alternatives;
|
||||
argparseOptions.action = 'append';
|
||||
break;
|
||||
}
|
||||
case BaseClasses_1.CommandLineParameterKind.Flag:
|
||||
argparseOptions.action = 'storeTrue';
|
||||
break;
|
||||
case BaseClasses_1.CommandLineParameterKind.Integer:
|
||||
argparseOptions.type = 'int';
|
||||
break;
|
||||
case BaseClasses_1.CommandLineParameterKind.IntegerList:
|
||||
argparseOptions.type = 'int';
|
||||
argparseOptions.action = 'append';
|
||||
break;
|
||||
case BaseClasses_1.CommandLineParameterKind.String:
|
||||
break;
|
||||
case BaseClasses_1.CommandLineParameterKind.StringList:
|
||||
argparseOptions.action = 'append';
|
||||
break;
|
||||
}
|
||||
let argumentGroup;
|
||||
if (parameter.parameterGroup) {
|
||||
argumentGroup = this._parameterGroupsByName.get(parameter.parameterGroup);
|
||||
if (!argumentGroup) {
|
||||
let parameterGroupName;
|
||||
if (typeof parameter.parameterGroup === 'string') {
|
||||
parameterGroupName = parameter.parameterGroup;
|
||||
}
|
||||
else if (parameter.parameterGroup === Constants_1.SCOPING_PARAMETER_GROUP) {
|
||||
parameterGroupName = 'scoping';
|
||||
}
|
||||
else {
|
||||
throw new Error('Unexpected parameter group: ' + parameter.parameterGroup);
|
||||
}
|
||||
argumentGroup = this._getArgumentParser().addArgumentGroup({
|
||||
title: `Optional ${parameterGroupName} arguments`
|
||||
});
|
||||
this._parameterGroupsByName.set(parameter.parameterGroup, argumentGroup);
|
||||
}
|
||||
}
|
||||
else {
|
||||
argumentGroup = this._getArgumentParser();
|
||||
}
|
||||
argumentGroup.addArgument(names, Object.assign({}, argparseOptions));
|
||||
if ((_a = parameter.undocumentedSynonyms) === null || _a === void 0 ? void 0 : _a.length) {
|
||||
argumentGroup.addArgument(parameter.undocumentedSynonyms, Object.assign(Object.assign({}, argparseOptions), { help: argparse.Const.SUPPRESS }));
|
||||
}
|
||||
// Register the parameter names so that we can detect ambiguous parameters
|
||||
for (const name of [...names, ...(parameter.undocumentedSynonyms || [])]) {
|
||||
this._registeredParameterParserKeysByName.set(name, parameter._parserKey);
|
||||
}
|
||||
}
|
||||
_registerAmbiguousParameter(name, parserKey) {
|
||||
this._getArgumentParser().addArgument(name, {
|
||||
dest: parserKey,
|
||||
// We don't know if this argument takes parameters or not, so we need to accept any number of args
|
||||
nargs: '*',
|
||||
// Ensure that the argument is not shown in the help text, since these parameters are only included
|
||||
// to inform the user that ambiguous parameters are present
|
||||
help: argparse.Const.SUPPRESS
|
||||
});
|
||||
}
|
||||
_generateKey() {
|
||||
return 'key_' + (CommandLineParameterProvider._keyCounter++).toString();
|
||||
}
|
||||
_getParameter(parameterLongName, expectedKind, parameterScope) {
|
||||
// Support the parameter long name being prefixed with the scope
|
||||
const { scope, longName } = this.parseScopedLongName(parameterLongName);
|
||||
parameterLongName = longName;
|
||||
parameterScope = scope || parameterScope;
|
||||
const parameters = this._parametersByLongName.get(parameterLongName);
|
||||
if (!parameters) {
|
||||
throw new Error(`The parameter "${parameterLongName}" is not defined`);
|
||||
}
|
||||
let parameter = parameters.find((p) => p.parameterScope === parameterScope);
|
||||
if (!parameter) {
|
||||
if (parameterScope !== undefined) {
|
||||
throw new Error(`The parameter "${parameterLongName}" with scope "${parameterScope}" is not defined.`);
|
||||
}
|
||||
if (parameters.length !== 1) {
|
||||
throw new Error(`The parameter "${parameterLongName}" is ambiguous. You must specify a scope.`);
|
||||
}
|
||||
parameter = parameters[0];
|
||||
}
|
||||
if (parameter.kind !== expectedKind) {
|
||||
throw new Error(`The parameter "${parameterLongName}" is of type "${BaseClasses_1.CommandLineParameterKind[parameter.kind]}"` +
|
||||
` whereas the caller was expecting "${BaseClasses_1.CommandLineParameterKind[expectedKind]}".`);
|
||||
}
|
||||
return parameter;
|
||||
}
|
||||
_throwParserExitError(parserOptions, data, errorCode, message) {
|
||||
// Write out the usage text to make it easier for the user to find the correct parameter name
|
||||
const targetActionName = data.aliasAction || data.action || '';
|
||||
const errorPrefix = `Error: ${parserOptions.toolFilename}` +
|
||||
// Handle aliases, actions, and actionless parameter providers
|
||||
`${targetActionName ? ' ' : ''}${targetActionName}: error: `;
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(this.renderUsageText());
|
||||
throw new CommandLineParserExitError_1.CommandLineParserExitError(errorCode, `${errorPrefix}${message.trimStart().trimEnd()}\n`);
|
||||
}
|
||||
}
|
||||
CommandLineParameterProvider._keyCounter = 0;
|
||||
exports.CommandLineParameterProvider = CommandLineParameterProvider;
|
||||
//# sourceMappingURL=CommandLineParameterProvider.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParameterProvider.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParameterProvider.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
107
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParser.d.ts
generated
vendored
Normal file
107
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParser.d.ts
generated
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
import type * as argparse from 'argparse';
|
||||
import type { CommandLineAction } from './CommandLineAction';
|
||||
import { CommandLineParameterProvider, type IRegisterDefinedParametersState } from './CommandLineParameterProvider';
|
||||
/**
|
||||
* Options for the {@link CommandLineParser} constructor.
|
||||
* @public
|
||||
*/
|
||||
export interface ICommandLineParserOptions {
|
||||
/**
|
||||
* The name of your tool when invoked from the command line
|
||||
*/
|
||||
toolFilename: string;
|
||||
/**
|
||||
* General documentation that is included in the "--help" main page
|
||||
*/
|
||||
toolDescription: string;
|
||||
/**
|
||||
* An optional string to append at the end of the "--help" main page. If not provided, an epilog
|
||||
* will be automatically generated based on the toolFilename.
|
||||
*/
|
||||
toolEpilog?: string;
|
||||
/**
|
||||
* Set to true to auto-define a tab completion action. False by default.
|
||||
*/
|
||||
enableTabCompletionAction?: boolean;
|
||||
}
|
||||
/**
|
||||
* The "argparse" library is a relatively advanced command-line parser with features such
|
||||
* as word-wrapping and intelligible error messages (that are lacking in other similar
|
||||
* libraries such as commander, yargs, and nomnom). Unfortunately, its ruby-inspired API
|
||||
* is awkward to use. The abstract base classes CommandLineParser and CommandLineAction
|
||||
* provide a wrapper for "argparse" that makes defining and consuming arguments quick
|
||||
* and simple, and enforces that appropriate documentation is provided for each parameter.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class CommandLineParser extends CommandLineParameterProvider {
|
||||
/**
|
||||
* Reports which CommandLineAction was specified on the command line.
|
||||
* @remarks
|
||||
* The value will be assigned before onExecute() is invoked.
|
||||
*/
|
||||
selectedAction: CommandLineAction | undefined;
|
||||
private readonly _argumentParser;
|
||||
private _actionsSubParser;
|
||||
private readonly _options;
|
||||
private readonly _actions;
|
||||
private readonly _actionsByName;
|
||||
private _executed;
|
||||
private _tabCompleteActionWasAdded;
|
||||
constructor(options: ICommandLineParserOptions);
|
||||
/**
|
||||
* Returns the list of actions that were defined for this CommandLineParser object.
|
||||
*/
|
||||
get actions(): ReadonlyArray<CommandLineAction>;
|
||||
/**
|
||||
* Defines a new action that can be used with the CommandLineParser instance.
|
||||
*/
|
||||
addAction(action: CommandLineAction): void;
|
||||
/**
|
||||
* Retrieves the action with the specified name. If no matching action is found,
|
||||
* an exception is thrown.
|
||||
*/
|
||||
getAction(actionName: string): CommandLineAction;
|
||||
/**
|
||||
* Retrieves the action with the specified name. If no matching action is found,
|
||||
* undefined is returned.
|
||||
*/
|
||||
tryGetAction(actionName: string): CommandLineAction | undefined;
|
||||
/**
|
||||
* The program entry point will call this method to begin parsing command-line arguments
|
||||
* and executing the corresponding action.
|
||||
*
|
||||
* @remarks
|
||||
* The returned promise will never reject: If an error occurs, it will be printed
|
||||
* to stderr, process.exitCode will be set to 1, and the promise will resolve to false.
|
||||
* This simplifies the most common usage scenario where the program entry point doesn't
|
||||
* want to be involved with the command-line logic, and will discard the promise without
|
||||
* a then() or catch() block.
|
||||
*
|
||||
* If your caller wants to trap and handle errors, use {@link CommandLineParser.executeWithoutErrorHandling}
|
||||
* instead.
|
||||
*
|
||||
* @param args - the command-line arguments to be parsed; if omitted, then
|
||||
* the process.argv will be used
|
||||
*/
|
||||
execute(args?: string[]): Promise<boolean>;
|
||||
/**
|
||||
* This is similar to {@link CommandLineParser.execute}, except that execution errors
|
||||
* simply cause the promise to reject. It is the caller's responsibility to trap
|
||||
*/
|
||||
executeWithoutErrorHandling(args?: string[]): Promise<void>;
|
||||
/** @internal */
|
||||
_registerDefinedParameters(state: IRegisterDefinedParametersState): void;
|
||||
private _validateDefinitions;
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameterProvider._getArgumentParser}
|
||||
* @internal
|
||||
*/
|
||||
protected _getArgumentParser(): argparse.ArgumentParser;
|
||||
/**
|
||||
* This hook allows the subclass to perform additional operations before or after
|
||||
* the chosen action is executed.
|
||||
*/
|
||||
protected onExecute(): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=CommandLineParser.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParser.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParser.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineParser.d.ts","sourceRoot":"","sources":["../../src/providers/CommandLineParser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,QAAQ,MAAM,UAAU,CAAC;AAG1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EACL,4BAA4B,EAC5B,KAAK,+BAA+B,EAErC,MAAM,gCAAgC,CAAC;AAIxC;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED;;;;;;;;;GASG;AACH,8BAAsB,iBAAkB,SAAQ,4BAA4B;IAC1E;;;;OAIG;IACI,cAAc,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAErD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA0B;IAC1D,OAAO,CAAC,iBAAiB,CAAiC;IAC1D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4B;IACrD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsB;IAC/C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiC;IAChE,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,0BAA0B,CAAkB;gBAEjC,OAAO,EAAE,yBAAyB;IAoBrD;;OAEG;IACH,IAAW,OAAO,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAErD;IAED;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAajD;;;OAGG;IACI,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB;IAQvD;;;OAGG;IACI,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAItE;;;;;;;;;;;;;;;;OAgBG;IACU,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IA0CvD;;;OAGG;IACU,2BAA2B,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA2ExE,gBAAgB;IACT,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,GAAG,IAAI;IAkB/E,OAAO,CAAC,oBAAoB;IAO5B;;;OAGG;IACH,SAAS,CAAC,kBAAkB,IAAI,QAAQ,CAAC,cAAc;IAKvD;;;OAGG;cACa,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAK3C"}
|
242
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParser.js
generated
vendored
Normal file
242
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParser.js
generated
vendored
Normal file
@ -0,0 +1,242 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CommandLineParser = void 0;
|
||||
const colors_1 = __importDefault(require("colors"));
|
||||
const CommandLineParameterProvider_1 = require("./CommandLineParameterProvider");
|
||||
const CommandLineParserExitError_1 = require("./CommandLineParserExitError");
|
||||
const TabCompletionAction_1 = require("./TabCompletionAction");
|
||||
/**
|
||||
* The "argparse" library is a relatively advanced command-line parser with features such
|
||||
* as word-wrapping and intelligible error messages (that are lacking in other similar
|
||||
* libraries such as commander, yargs, and nomnom). Unfortunately, its ruby-inspired API
|
||||
* is awkward to use. The abstract base classes CommandLineParser and CommandLineAction
|
||||
* provide a wrapper for "argparse" that makes defining and consuming arguments quick
|
||||
* and simple, and enforces that appropriate documentation is provided for each parameter.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
class CommandLineParser extends CommandLineParameterProvider_1.CommandLineParameterProvider {
|
||||
constructor(options) {
|
||||
var _a, _b;
|
||||
super();
|
||||
this._executed = false;
|
||||
this._tabCompleteActionWasAdded = false;
|
||||
this._options = options;
|
||||
this._actions = [];
|
||||
this._actionsByName = new Map();
|
||||
this._argumentParser = new CommandLineParserExitError_1.CustomArgumentParser({
|
||||
addHelp: true,
|
||||
prog: this._options.toolFilename,
|
||||
description: this._options.toolDescription,
|
||||
epilog: colors_1.default.bold((_a = this._options.toolEpilog) !== null && _a !== void 0 ? _a : `For detailed help about a specific command, use: ${this._options.toolFilename} <command> -h`)
|
||||
});
|
||||
(_b = this.onDefineParameters) === null || _b === void 0 ? void 0 : _b.call(this);
|
||||
}
|
||||
/**
|
||||
* Returns the list of actions that were defined for this CommandLineParser object.
|
||||
*/
|
||||
get actions() {
|
||||
return this._actions;
|
||||
}
|
||||
/**
|
||||
* Defines a new action that can be used with the CommandLineParser instance.
|
||||
*/
|
||||
addAction(action) {
|
||||
if (!this._actionsSubParser) {
|
||||
this._actionsSubParser = this._argumentParser.addSubparsers({
|
||||
metavar: '<command>',
|
||||
dest: 'action'
|
||||
});
|
||||
}
|
||||
action._buildParser(this._actionsSubParser);
|
||||
this._actions.push(action);
|
||||
this._actionsByName.set(action.actionName, action);
|
||||
}
|
||||
/**
|
||||
* Retrieves the action with the specified name. If no matching action is found,
|
||||
* an exception is thrown.
|
||||
*/
|
||||
getAction(actionName) {
|
||||
const action = this.tryGetAction(actionName);
|
||||
if (!action) {
|
||||
throw new Error(`The action "${actionName}" was not defined`);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
/**
|
||||
* Retrieves the action with the specified name. If no matching action is found,
|
||||
* undefined is returned.
|
||||
*/
|
||||
tryGetAction(actionName) {
|
||||
return this._actionsByName.get(actionName);
|
||||
}
|
||||
/**
|
||||
* The program entry point will call this method to begin parsing command-line arguments
|
||||
* and executing the corresponding action.
|
||||
*
|
||||
* @remarks
|
||||
* The returned promise will never reject: If an error occurs, it will be printed
|
||||
* to stderr, process.exitCode will be set to 1, and the promise will resolve to false.
|
||||
* This simplifies the most common usage scenario where the program entry point doesn't
|
||||
* want to be involved with the command-line logic, and will discard the promise without
|
||||
* a then() or catch() block.
|
||||
*
|
||||
* If your caller wants to trap and handle errors, use {@link CommandLineParser.executeWithoutErrorHandling}
|
||||
* instead.
|
||||
*
|
||||
* @param args - the command-line arguments to be parsed; if omitted, then
|
||||
* the process.argv will be used
|
||||
*/
|
||||
async execute(args) {
|
||||
if (this._options.enableTabCompletionAction && !this._tabCompleteActionWasAdded) {
|
||||
this.addAction(new TabCompletionAction_1.TabCompleteAction(this.actions, this.parameters));
|
||||
this._tabCompleteActionWasAdded = true;
|
||||
}
|
||||
try {
|
||||
await this.executeWithoutErrorHandling(args);
|
||||
return true;
|
||||
}
|
||||
catch (err) {
|
||||
if (err instanceof CommandLineParserExitError_1.CommandLineParserExitError) {
|
||||
// executeWithoutErrorHandling() handles the successful cases,
|
||||
// so here we can assume err has a nonzero exit code
|
||||
if (err.message) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err.message);
|
||||
}
|
||||
if (!process.exitCode) {
|
||||
process.exitCode = err.exitCode;
|
||||
}
|
||||
}
|
||||
else {
|
||||
let message = (err.message || 'An unknown error occurred').trim();
|
||||
// If the message doesn't already start with "Error:" then add a prefix
|
||||
if (!/^(error|internal error|warning)\b/i.test(message)) {
|
||||
message = 'Error: ' + message;
|
||||
}
|
||||
// eslint-disable-next-line no-console
|
||||
console.error();
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(colors_1.default.red(message));
|
||||
if (!process.exitCode) {
|
||||
process.exitCode = 1;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This is similar to {@link CommandLineParser.execute}, except that execution errors
|
||||
* simply cause the promise to reject. It is the caller's responsibility to trap
|
||||
*/
|
||||
async executeWithoutErrorHandling(args) {
|
||||
var _a, _b;
|
||||
try {
|
||||
if (this._executed) {
|
||||
// In the future we could allow the same parser to be invoked multiple times
|
||||
// with different arguments. We'll do that work as soon as someone encounters
|
||||
// a real world need for it.
|
||||
throw new Error('execute() was already called for this parser instance');
|
||||
}
|
||||
this._executed = true;
|
||||
this._validateDefinitions();
|
||||
// Register the parameters before we print help or parse the CLI
|
||||
const initialState = {
|
||||
parentParameterNames: new Set()
|
||||
};
|
||||
this._registerDefinedParameters(initialState);
|
||||
if (!args) {
|
||||
// 0=node.exe, 1=script name
|
||||
args = process.argv.slice(2);
|
||||
}
|
||||
if (this.actions.length > 0) {
|
||||
if (args.length === 0) {
|
||||
// Parsers that use actions should print help when 0 args are provided. Allow
|
||||
// actionless parsers to continue on zero args.
|
||||
this._argumentParser.printHelp();
|
||||
return;
|
||||
}
|
||||
// Alias actions may provide a list of default params to add after the action name.
|
||||
// Since we don't know which params are required and which are optional, perform a
|
||||
// manual search for the action name to obtain the default params and insert them if
|
||||
// any are found. We will guess that the action name is the first arg that doesn't
|
||||
// start with a hyphen.
|
||||
const actionNameIndex = args.findIndex((x) => !x.startsWith('-'));
|
||||
if (actionNameIndex !== undefined) {
|
||||
const actionName = args[actionNameIndex];
|
||||
const action = this.tryGetAction(actionName);
|
||||
const aliasAction = action;
|
||||
if ((_a = aliasAction === null || aliasAction === void 0 ? void 0 : aliasAction.defaultParameters) === null || _a === void 0 ? void 0 : _a.length) {
|
||||
const insertIndex = actionNameIndex + 1;
|
||||
args = args.slice(0, insertIndex).concat(aliasAction.defaultParameters, args.slice(insertIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
const data = this._argumentParser.parseArgs(args);
|
||||
this._processParsedData(this._options, data);
|
||||
this.selectedAction = this.tryGetAction(data.action);
|
||||
if (this.actions.length > 0 && !this.selectedAction) {
|
||||
const actions = this.actions.map((x) => x.actionName);
|
||||
throw new Error(`An action must be specified (${actions.join(', ')})`);
|
||||
}
|
||||
(_b = this.selectedAction) === null || _b === void 0 ? void 0 : _b._processParsedData(this._options, data);
|
||||
await this.onExecute();
|
||||
}
|
||||
catch (err) {
|
||||
if (err instanceof CommandLineParserExitError_1.CommandLineParserExitError) {
|
||||
if (!err.exitCode) {
|
||||
// non-error exit modeled using exception handling
|
||||
if (err.message) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(err.message);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
/** @internal */
|
||||
_registerDefinedParameters(state) {
|
||||
super._registerDefinedParameters(state);
|
||||
const { parentParameterNames } = state;
|
||||
const updatedParentParameterNames = new Set([
|
||||
...parentParameterNames,
|
||||
...this._registeredParameterParserKeysByName.keys()
|
||||
]);
|
||||
const parentState = Object.assign(Object.assign({}, state), { parentParameterNames: updatedParentParameterNames });
|
||||
for (const action of this._actions) {
|
||||
action._registerDefinedParameters(parentState);
|
||||
}
|
||||
}
|
||||
_validateDefinitions() {
|
||||
if (this.remainder && this.actions.length > 0) {
|
||||
// This is apparently not supported by argparse
|
||||
throw new Error('defineCommandLineRemainder() cannot be called for a CommandLineParser with actions');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameterProvider._getArgumentParser}
|
||||
* @internal
|
||||
*/
|
||||
_getArgumentParser() {
|
||||
// override
|
||||
return this._argumentParser;
|
||||
}
|
||||
/**
|
||||
* This hook allows the subclass to perform additional operations before or after
|
||||
* the chosen action is executed.
|
||||
*/
|
||||
async onExecute() {
|
||||
if (this.selectedAction) {
|
||||
await this.selectedAction._execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.CommandLineParser = CommandLineParser;
|
||||
//# sourceMappingURL=CommandLineParser.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParser.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParser.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
10
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParserExitError.d.ts
generated
vendored
Normal file
10
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParserExitError.d.ts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import * as argparse from 'argparse';
|
||||
export declare class CommandLineParserExitError extends Error {
|
||||
readonly exitCode: number;
|
||||
constructor(exitCode: number, message: string);
|
||||
}
|
||||
export declare class CustomArgumentParser extends argparse.ArgumentParser {
|
||||
exit(status: number, message: string): void;
|
||||
error(err: Error | string): void;
|
||||
}
|
||||
//# sourceMappingURL=CommandLineParserExitError.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParserExitError.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParserExitError.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineParserExitError.d.ts","sourceRoot":"","sources":["../../src/providers/CommandLineParserExitError.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAEd,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAWrD;AAED,qBAAa,oBAAqB,SAAQ,QAAQ,CAAC,cAAc;IACxD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAK3C,KAAK,CAAC,GAAG,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI;CASxC"}
|
57
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParserExitError.js
generated
vendored
Normal file
57
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParserExitError.js
generated
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CustomArgumentParser = exports.CommandLineParserExitError = void 0;
|
||||
const argparse = __importStar(require("argparse"));
|
||||
class CommandLineParserExitError extends Error {
|
||||
constructor(exitCode, message) {
|
||||
super(message);
|
||||
// Manually set the prototype, as we can no longer extend built-in classes like Error, Array, Map, etc
|
||||
// https://github.com/microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
||||
//
|
||||
// Note: the prototype must also be set on any classes which extend this one
|
||||
this.__proto__ = CommandLineParserExitError.prototype; // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
this.exitCode = exitCode;
|
||||
}
|
||||
}
|
||||
exports.CommandLineParserExitError = CommandLineParserExitError;
|
||||
class CustomArgumentParser extends argparse.ArgumentParser {
|
||||
exit(status, message) {
|
||||
// override
|
||||
throw new CommandLineParserExitError(status, message);
|
||||
}
|
||||
error(err) {
|
||||
// override
|
||||
// Ensure the ParserExitError bubbles up to the top without any special processing
|
||||
if (err instanceof CommandLineParserExitError) {
|
||||
throw err;
|
||||
}
|
||||
super.error(err);
|
||||
}
|
||||
}
|
||||
exports.CustomArgumentParser = CustomArgumentParser;
|
||||
//# sourceMappingURL=CommandLineParserExitError.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParserExitError.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParserExitError.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CommandLineParserExitError.js","sourceRoot":"","sources":["../../src/providers/CommandLineParserExitError.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,mDAAqC;AAErC,MAAa,0BAA2B,SAAQ,KAAK;IAGnD,YAAmB,QAAgB,EAAE,OAAe;QAClD,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,sGAAsG;QACtG,6IAA6I;QAC7I,EAAE;QACF,4EAA4E;QAC3E,IAAY,CAAC,SAAS,GAAG,0BAA0B,CAAC,SAAS,CAAC,CAAC,yDAAyD;QAEzH,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAdD,gEAcC;AAED,MAAa,oBAAqB,SAAQ,QAAQ,CAAC,cAAc;IACxD,IAAI,CAAC,MAAc,EAAE,OAAe;QACzC,WAAW;QACX,MAAM,IAAI,0BAA0B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IAEM,KAAK,CAAC,GAAmB;QAC9B,WAAW;QACX,kFAAkF;QAClF,IAAI,GAAG,YAAY,0BAA0B,EAAE;YAC7C,MAAM,GAAG,CAAC;SACX;QAED,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;CACF;AAfD,oDAeC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as argparse from 'argparse';\n\nexport class CommandLineParserExitError extends Error {\n public readonly exitCode: number;\n\n public constructor(exitCode: number, message: string) {\n super(message);\n\n // Manually set the prototype, as we can no longer extend built-in classes like Error, Array, Map, etc\n // https://github.com/microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\n //\n // Note: the prototype must also be set on any classes which extend this one\n (this as any).__proto__ = CommandLineParserExitError.prototype; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n this.exitCode = exitCode;\n }\n}\n\nexport class CustomArgumentParser extends argparse.ArgumentParser {\n public exit(status: number, message: string): void {\n // override\n throw new CommandLineParserExitError(status, message);\n }\n\n public error(err: Error | string): void {\n // override\n // Ensure the ParserExitError bubbles up to the top without any special processing\n if (err instanceof CommandLineParserExitError) {\n throw err;\n }\n\n super.error(err);\n }\n}\n"]}
|
8
node_modules/@rushstack/ts-command-line/lib/providers/DynamicCommandLineAction.d.ts
generated
vendored
Normal file
8
node_modules/@rushstack/ts-command-line/lib/providers/DynamicCommandLineAction.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
import { CommandLineAction } from './CommandLineAction';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export declare class DynamicCommandLineAction extends CommandLineAction {
|
||||
protected onExecute(): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=DynamicCommandLineAction.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/DynamicCommandLineAction.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/DynamicCommandLineAction.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"DynamicCommandLineAction.d.ts","sourceRoot":"","sources":["../../src/providers/DynamicCommandLineAction.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,iBAAiB;cAC7C,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAI3C"}
|
17
node_modules/@rushstack/ts-command-line/lib/providers/DynamicCommandLineAction.js
generated
vendored
Normal file
17
node_modules/@rushstack/ts-command-line/lib/providers/DynamicCommandLineAction.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DynamicCommandLineAction = void 0;
|
||||
const CommandLineAction_1 = require("./CommandLineAction");
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
class DynamicCommandLineAction extends CommandLineAction_1.CommandLineAction {
|
||||
async onExecute() {
|
||||
// abstract
|
||||
// (handled by the external code)
|
||||
}
|
||||
}
|
||||
exports.DynamicCommandLineAction = DynamicCommandLineAction;
|
||||
//# sourceMappingURL=DynamicCommandLineAction.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/DynamicCommandLineAction.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/DynamicCommandLineAction.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"DynamicCommandLineAction.js","sourceRoot":"","sources":["../../src/providers/DynamicCommandLineAction.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,2DAAwD;AAExD;;GAEG;AACH,MAAa,wBAAyB,SAAQ,qCAAiB;IACnD,KAAK,CAAC,SAAS;QACvB,WAAW;QACX,iCAAiC;IACnC,CAAC;CACF;AALD,4DAKC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { CommandLineAction } from './CommandLineAction';\n\n/**\n * @public\n */\nexport class DynamicCommandLineAction extends CommandLineAction {\n protected async onExecute(): Promise<void> {\n // abstract\n // (handled by the external code)\n }\n}\n"]}
|
7
node_modules/@rushstack/ts-command-line/lib/providers/DynamicCommandLineParser.d.ts
generated
vendored
Normal file
7
node_modules/@rushstack/ts-command-line/lib/providers/DynamicCommandLineParser.d.ts
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import { CommandLineParser } from './CommandLineParser';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export declare class DynamicCommandLineParser extends CommandLineParser {
|
||||
}
|
||||
//# sourceMappingURL=DynamicCommandLineParser.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/DynamicCommandLineParser.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/DynamicCommandLineParser.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"DynamicCommandLineParser.d.ts","sourceRoot":"","sources":["../../src/providers/DynamicCommandLineParser.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,iBAAiB;CAAG"}
|
13
node_modules/@rushstack/ts-command-line/lib/providers/DynamicCommandLineParser.js
generated
vendored
Normal file
13
node_modules/@rushstack/ts-command-line/lib/providers/DynamicCommandLineParser.js
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DynamicCommandLineParser = void 0;
|
||||
const CommandLineParser_1 = require("./CommandLineParser");
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
class DynamicCommandLineParser extends CommandLineParser_1.CommandLineParser {
|
||||
}
|
||||
exports.DynamicCommandLineParser = DynamicCommandLineParser;
|
||||
//# sourceMappingURL=DynamicCommandLineParser.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/DynamicCommandLineParser.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/DynamicCommandLineParser.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"DynamicCommandLineParser.js","sourceRoot":"","sources":["../../src/providers/DynamicCommandLineParser.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,2DAAwD;AAExD;;GAEG;AACH,MAAa,wBAAyB,SAAQ,qCAAiB;CAAG;AAAlE,4DAAkE","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { CommandLineParser } from './CommandLineParser';\n\n/**\n * @public\n */\nexport class DynamicCommandLineParser extends CommandLineParser {}\n"]}
|
88
node_modules/@rushstack/ts-command-line/lib/providers/ScopedCommandLineAction.d.ts
generated
vendored
Normal file
88
node_modules/@rushstack/ts-command-line/lib/providers/ScopedCommandLineAction.d.ts
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
import { SCOPING_PARAMETER_GROUP } from '../Constants';
|
||||
import { CommandLineAction, type ICommandLineActionOptions } from './CommandLineAction';
|
||||
import { CommandLineParser, type ICommandLineParserOptions } from './CommandLineParser';
|
||||
import type { CommandLineParameter } from '../parameters/BaseClasses';
|
||||
import type { CommandLineParameterProvider, ICommandLineParserData, IRegisterDefinedParametersState } from './CommandLineParameterProvider';
|
||||
/**
|
||||
* Represents a sub-command that is part of the CommandLineParser command-line.
|
||||
* Applications should create subclasses of ScopedCommandLineAction corresponding to
|
||||
* each action that they want to expose.
|
||||
*
|
||||
* The action name should be comprised of lower case words separated by hyphens
|
||||
* or colons. The name should include an English verb (e.g. "deploy"). Use a
|
||||
* hyphen to separate words (e.g. "upload-docs"). A group of related commands
|
||||
* can be prefixed with a colon (e.g. "docs:generate", "docs:deploy",
|
||||
* "docs:serve", etc).
|
||||
*
|
||||
* Scoped commands allow for different parameters to be specified for different
|
||||
* provided scoping values. For example, the "scoped-action --scope A" command
|
||||
* may allow for different scoped arguments to be specified than the "scoped-action
|
||||
* --scope B" command.
|
||||
*
|
||||
* Scoped arguments are specified after the "--" pseudo-argument. For example,
|
||||
* "scoped-action --scope A -- --scopedFoo --scopedBar".
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class ScopedCommandLineAction extends CommandLineAction {
|
||||
private _options;
|
||||
private _scopingParameters;
|
||||
private _unscopedParserOptions;
|
||||
private _scopedCommandLineParser;
|
||||
private _subparserState;
|
||||
/**
|
||||
* The required group name to apply to all scoping parameters. At least one parameter
|
||||
* must be defined with this group name.
|
||||
*/
|
||||
static readonly ScopingParameterGroup: typeof SCOPING_PARAMETER_GROUP;
|
||||
constructor(options: ICommandLineActionOptions);
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameterProvider.parameters}
|
||||
*/
|
||||
get parameters(): ReadonlyArray<CommandLineParameter>;
|
||||
/**
|
||||
* {@inheritdoc CommandLineAction._processParsedData}
|
||||
* @internal
|
||||
*/
|
||||
_processParsedData(parserOptions: ICommandLineParserOptions, data: ICommandLineParserData): void;
|
||||
/**
|
||||
* {@inheritdoc CommandLineAction._execute}
|
||||
* @internal
|
||||
*/
|
||||
_execute(): Promise<void>;
|
||||
/** @internal */
|
||||
_registerDefinedParameters(state: IRegisterDefinedParametersState): void;
|
||||
/**
|
||||
* {@inheritdoc CommandLineParameterProvider.onDefineParameters}
|
||||
*/
|
||||
protected onDefineParameters(): void;
|
||||
/**
|
||||
* Retrieves the scoped CommandLineParser, which is populated after the ScopedCommandLineAction is executed.
|
||||
* @internal
|
||||
*/
|
||||
protected _getScopedCommandLineParser(): CommandLineParser;
|
||||
/** @internal */
|
||||
protected _defineParameter(parameter: CommandLineParameter): void;
|
||||
/**
|
||||
* The child class should implement this hook to define its unscoped command-line parameters,
|
||||
* e.g. by calling defineFlagParameter(). At least one scoping parameter must be defined.
|
||||
* Scoping parameters are defined by setting the parameterGroupName to
|
||||
* ScopedCommandLineAction.ScopingParameterGroupName.
|
||||
*/
|
||||
protected onDefineUnscopedParameters?(): void;
|
||||
/**
|
||||
* The child class should implement this hook to define its scoped command-line
|
||||
* parameters, e.g. by calling scopedParameterProvider.defineFlagParameter(). These
|
||||
* parameters will only be available if the action is invoked with a scope.
|
||||
*
|
||||
* @remarks
|
||||
* onDefineScopedParameters is called after the unscoped parameters have been parsed.
|
||||
* The values they provide can be used to vary the defined scope parameters.
|
||||
*/
|
||||
protected abstract onDefineScopedParameters(scopedParameterProvider: CommandLineParameterProvider): void;
|
||||
/**
|
||||
* {@inheritDoc CommandLineAction.onExecute}
|
||||
*/
|
||||
protected abstract onExecute(): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=ScopedCommandLineAction.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/ScopedCommandLineAction.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/ScopedCommandLineAction.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"ScopedCommandLineAction.d.ts","sourceRoot":"","sources":["../../src/providers/ScopedCommandLineAction.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,KAAK,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,KAAK,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAExF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EACV,4BAA4B,EAC5B,sBAAsB,EACtB,+BAA+B,EAChC,MAAM,gCAAgC,CAAC;AAmExC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,8BAAsB,uBAAwB,SAAQ,iBAAiB;IACrE,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,kBAAkB,CAAyB;IACnD,OAAO,CAAC,sBAAsB,CAAwC;IACtE,OAAO,CAAC,wBAAwB,CAA8C;IAC9E,OAAO,CAAC,eAAe,CAA8C;IAErE;;;OAGG;IACH,gBAAuB,qBAAqB,EAAE,OAAO,uBAAuB,CAA2B;gBAEpF,OAAO,EAAE,yBAAyB;IAOrD;;OAEG;IACH,IAAW,UAAU,IAAI,aAAa,CAAC,oBAAoB,CAAC,CAM3D;IAED;;;OAGG;IACI,kBAAkB,CAAC,aAAa,EAAE,yBAAyB,EAAE,IAAI,EAAE,sBAAsB,GAAG,IAAI;IAyBvG;;;OAGG;IACU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAuCtC,gBAAgB;IACT,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,GAAG,IAAI;IAe/E;;OAEG;IACH,SAAS,CAAC,kBAAkB,IAAI,IAAI;IA2BpC;;;OAGG;IACH,SAAS,CAAC,2BAA2B,IAAI,iBAAiB;IAO1D,gBAAgB;IAChB,SAAS,CAAC,gBAAgB,CAAC,SAAS,EAAE,oBAAoB,GAAG,IAAI;IAOjE;;;;;OAKG;IACH,SAAS,CAAC,0BAA0B,CAAC,IAAI,IAAI;IAE7C;;;;;;;;OAQG;IACH,SAAS,CAAC,QAAQ,CAAC,wBAAwB,CAAC,uBAAuB,EAAE,4BAA4B,GAAG,IAAI;IAExG;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAC9C"}
|
204
node_modules/@rushstack/ts-command-line/lib/providers/ScopedCommandLineAction.js
generated
vendored
Normal file
204
node_modules/@rushstack/ts-command-line/lib/providers/ScopedCommandLineAction.js
generated
vendored
Normal file
@ -0,0 +1,204 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ScopedCommandLineAction = void 0;
|
||||
const Constants_1 = require("../Constants");
|
||||
const CommandLineAction_1 = require("./CommandLineAction");
|
||||
const CommandLineParser_1 = require("./CommandLineParser");
|
||||
const CommandLineParserExitError_1 = require("./CommandLineParserExitError");
|
||||
/**
|
||||
* A CommandLineParser used exclusively to parse the scoped command-line parameters
|
||||
* for a ScopedCommandLineAction.
|
||||
*/
|
||||
class InternalScopedCommandLineParser extends CommandLineParser_1.CommandLineParser {
|
||||
get canExecute() {
|
||||
return this._canExecute;
|
||||
}
|
||||
constructor(options) {
|
||||
const { actionOptions, unscopedActionParameters, toolFilename, aliasAction, aliasDocumentation } = options;
|
||||
const toolCommand = `${toolFilename} ${actionOptions.actionName}`;
|
||||
// When coming from an alias command, we want to show the alias command name in the help text
|
||||
const toolCommandForLogging = `${toolFilename} ${aliasAction !== null && aliasAction !== void 0 ? aliasAction : actionOptions.actionName}`;
|
||||
const scopingArgs = [];
|
||||
for (const parameter of unscopedActionParameters) {
|
||||
parameter.appendToArgList(scopingArgs);
|
||||
}
|
||||
const scope = scopingArgs.join(' ');
|
||||
// We can run the parser directly because we are not going to use it for any other actions,
|
||||
// so construct a special options object to make the "--help" text more useful.
|
||||
const scopedCommandLineParserOptions = {
|
||||
// Strip the scoping args if coming from an alias command, since they are not applicable
|
||||
// to the alias command itself
|
||||
toolFilename: `${toolCommandForLogging}${scope && !aliasAction ? ` ${scope} --` : ''}`,
|
||||
toolDescription: aliasDocumentation !== null && aliasDocumentation !== void 0 ? aliasDocumentation : actionOptions.documentation,
|
||||
toolEpilog: `For more information on available unscoped parameters, use "${toolCommand} --help"`,
|
||||
enableTabCompletionAction: false
|
||||
};
|
||||
super(scopedCommandLineParserOptions);
|
||||
this._canExecute = false;
|
||||
this._internalOptions = options;
|
||||
this._internalOptions.onDefineScopedParameters(this);
|
||||
}
|
||||
_registerDefinedParameters(state) {
|
||||
// Since we are in a separate parser, we need to register the parameters using the state
|
||||
// from the parent parser.
|
||||
super._registerDefinedParameters(this._internalOptions.registerDefinedParametersState);
|
||||
}
|
||||
async onExecute() {
|
||||
// override
|
||||
// Only set if we made it this far, which may not be the case if an error occurred or
|
||||
// if '--help' was specified.
|
||||
this._canExecute = true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Represents a sub-command that is part of the CommandLineParser command-line.
|
||||
* Applications should create subclasses of ScopedCommandLineAction corresponding to
|
||||
* each action that they want to expose.
|
||||
*
|
||||
* The action name should be comprised of lower case words separated by hyphens
|
||||
* or colons. The name should include an English verb (e.g. "deploy"). Use a
|
||||
* hyphen to separate words (e.g. "upload-docs"). A group of related commands
|
||||
* can be prefixed with a colon (e.g. "docs:generate", "docs:deploy",
|
||||
* "docs:serve", etc).
|
||||
*
|
||||
* Scoped commands allow for different parameters to be specified for different
|
||||
* provided scoping values. For example, the "scoped-action --scope A" command
|
||||
* may allow for different scoped arguments to be specified than the "scoped-action
|
||||
* --scope B" command.
|
||||
*
|
||||
* Scoped arguments are specified after the "--" pseudo-argument. For example,
|
||||
* "scoped-action --scope A -- --scopedFoo --scopedBar".
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
class ScopedCommandLineAction extends CommandLineAction_1.CommandLineAction {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this._options = options;
|
||||
this._scopingParameters = [];
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc CommandLineParameterProvider.parameters}
|
||||
*/
|
||||
get parameters() {
|
||||
if (this._scopedCommandLineParser) {
|
||||
return [...super.parameters, ...this._scopedCommandLineParser.parameters];
|
||||
}
|
||||
else {
|
||||
return super.parameters;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc CommandLineAction._processParsedData}
|
||||
* @internal
|
||||
*/
|
||||
_processParsedData(parserOptions, data) {
|
||||
// override
|
||||
super._processParsedData(parserOptions, data);
|
||||
// This should never happen because the super method should throw if parameters haven't been registered,
|
||||
// but guard against this just in-case.
|
||||
if (this._subparserState === undefined) {
|
||||
throw new Error('Parameters have not been registered');
|
||||
}
|
||||
this._unscopedParserOptions = parserOptions;
|
||||
// Generate the scoped parser using the parent parser information. We can only create this after we
|
||||
// have parsed the data, since the parameter values are used during construction.
|
||||
this._scopedCommandLineParser = new InternalScopedCommandLineParser(Object.assign(Object.assign({}, parserOptions), { actionOptions: this._options, aliasAction: data.aliasAction, aliasDocumentation: data.aliasDocumentation, unscopedActionParameters: this.parameters, registerDefinedParametersState: this._subparserState, onDefineScopedParameters: this.onDefineScopedParameters.bind(this) }));
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc CommandLineAction._execute}
|
||||
* @internal
|
||||
*/
|
||||
async _execute() {
|
||||
// override
|
||||
if (!this._unscopedParserOptions || !this._scopedCommandLineParser) {
|
||||
throw new Error('The CommandLineAction parameters must be processed before execution.');
|
||||
}
|
||||
if (!this.remainder) {
|
||||
throw new Error('CommandLineAction.onDefineParameters must be called before execution.');
|
||||
}
|
||||
// The '--' argument is required to separate the action parameters from the scoped parameters,
|
||||
// so it needs to be trimmed. If remainder values are provided but no '--' is found, then throw.
|
||||
const scopedArgs = [];
|
||||
if (this.remainder.values.length) {
|
||||
if (this.remainder.values[0] !== '--') {
|
||||
throw new CommandLineParserExitError_1.CommandLineParserExitError(
|
||||
// argparse sets exit code 2 for invalid arguments
|
||||
2,
|
||||
// model the message off of the built-in "unrecognized arguments" message
|
||||
`${this.renderUsageText()}\n${this._unscopedParserOptions.toolFilename} ${this.actionName}: ` +
|
||||
`error: Unrecognized arguments: ${this.remainder.values[0]}.\n`);
|
||||
}
|
||||
for (const scopedArg of this.remainder.values.slice(1)) {
|
||||
scopedArgs.push(scopedArg);
|
||||
}
|
||||
}
|
||||
// Call the scoped parser using only the scoped args to handle parsing
|
||||
await this._scopedCommandLineParser.executeWithoutErrorHandling(scopedArgs);
|
||||
// Only call execute if the parser reached the execute stage. This may not be true if
|
||||
// the parser exited early due to a specified '--help' parameter.
|
||||
if (this._scopedCommandLineParser.canExecute) {
|
||||
await super._execute();
|
||||
}
|
||||
return;
|
||||
}
|
||||
/** @internal */
|
||||
_registerDefinedParameters(state) {
|
||||
super._registerDefinedParameters(state);
|
||||
const { parentParameterNames } = state;
|
||||
const updatedParentParameterNames = new Set([
|
||||
...parentParameterNames,
|
||||
...this._registeredParameterParserKeysByName.keys()
|
||||
]);
|
||||
this._subparserState = Object.assign(Object.assign({}, state), { parentParameterNames: updatedParentParameterNames });
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc CommandLineParameterProvider.onDefineParameters}
|
||||
*/
|
||||
onDefineParameters() {
|
||||
var _a;
|
||||
(_a = this.onDefineUnscopedParameters) === null || _a === void 0 ? void 0 : _a.call(this);
|
||||
if (!this._scopingParameters.length) {
|
||||
throw new Error('No scoping parameters defined. At least one scoping parameter must be defined. ' +
|
||||
'Scoping parameters are defined by setting the parameterGroupName to ' +
|
||||
'ScopedCommandLineAction.ScopingParameterGroupName.');
|
||||
}
|
||||
if (this.remainder) {
|
||||
throw new Error('Unscoped remainder parameters are not allowed. Remainder parameters can only be defined on ' +
|
||||
'the scoped parameter provider in onDefineScopedParameters().');
|
||||
}
|
||||
// Consume the remainder of the command-line, which will later be passed the scoped parser.
|
||||
// This will also prevent developers from calling this.defineCommandLineRemainder(...) since
|
||||
// we will have already defined it.
|
||||
this.defineCommandLineRemainder({
|
||||
description: 'Scoped parameters. Must be prefixed with "--", ex. "-- --scopedParameter ' +
|
||||
'foo --scopedFlag". For more information on available scoped parameters, use "-- --help".'
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Retrieves the scoped CommandLineParser, which is populated after the ScopedCommandLineAction is executed.
|
||||
* @internal
|
||||
*/
|
||||
_getScopedCommandLineParser() {
|
||||
if (!this._scopedCommandLineParser) {
|
||||
throw new Error('The scoped CommandLineParser is only populated after the action is executed.');
|
||||
}
|
||||
return this._scopedCommandLineParser;
|
||||
}
|
||||
/** @internal */
|
||||
_defineParameter(parameter) {
|
||||
super._defineParameter(parameter);
|
||||
if (parameter.parameterGroup === ScopedCommandLineAction.ScopingParameterGroup) {
|
||||
this._scopingParameters.push(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The required group name to apply to all scoping parameters. At least one parameter
|
||||
* must be defined with this group name.
|
||||
*/
|
||||
ScopedCommandLineAction.ScopingParameterGroup = Constants_1.SCOPING_PARAMETER_GROUP;
|
||||
exports.ScopedCommandLineAction = ScopedCommandLineAction;
|
||||
//# sourceMappingURL=ScopedCommandLineAction.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/ScopedCommandLineAction.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/ScopedCommandLineAction.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
17
node_modules/@rushstack/ts-command-line/lib/providers/TabCompletionAction.d.ts
generated
vendored
Normal file
17
node_modules/@rushstack/ts-command-line/lib/providers/TabCompletionAction.d.ts
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
import { type CommandLineParameter } from '../parameters/BaseClasses';
|
||||
import { CommandLineAction } from './CommandLineAction';
|
||||
export declare class TabCompleteAction extends CommandLineAction {
|
||||
private readonly _wordToCompleteParameter;
|
||||
private readonly _positionParameter;
|
||||
private readonly _actions;
|
||||
private readonly _globalParameters;
|
||||
constructor(actions: ReadonlyArray<CommandLineAction>, globalParameters: ReadonlyArray<CommandLineParameter>);
|
||||
protected onExecute(): Promise<void>;
|
||||
getCompletions(commandLine: string, caretPosition?: number): AsyncIterable<string>;
|
||||
private _getAllActions;
|
||||
tokenizeCommandLine(commandLine: string): string[];
|
||||
private _getParameterValueCompletions;
|
||||
private _getGlobalParameterOffset;
|
||||
private _completeParameterValues;
|
||||
}
|
||||
//# sourceMappingURL=TabCompletionAction.d.ts.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/TabCompletionAction.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/TabCompletionAction.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"TabCompletionAction.d.ts","sourceRoot":"","sources":["../../src/providers/TabCompletionAction.ts"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,oBAAoB,EAE1B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAMxD,qBAAa,iBAAkB,SAAQ,iBAAiB;IACtD,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAA6B;IACtE,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA8B;IACjE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiD;IAC1E,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAoC;gBAGpE,OAAO,EAAE,aAAa,CAAC,iBAAiB,CAAC,EACzC,gBAAgB,EAAE,aAAa,CAAC,oBAAoB,CAAC;cA8CvC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAU5B,cAAc,CAC1B,WAAW,EAAE,MAAM,EACnB,aAAa,GAAE,MAA2B,GACzC,aAAa,CAAC,MAAM,CAAC;IAgFxB,OAAO,CAAE,cAAc;IAKhB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE;YAI3C,6BAA6B;IAsB3C,OAAO,CAAC,yBAAyB;IAgBjC,OAAO,CAAE,wBAAwB;CAUlC"}
|
217
node_modules/@rushstack/ts-command-line/lib/providers/TabCompletionAction.js
generated
vendored
Normal file
217
node_modules/@rushstack/ts-command-line/lib/providers/TabCompletionAction.js
generated
vendored
Normal file
@ -0,0 +1,217 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var m = o[Symbol.asyncIterator], i;
|
||||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||
};
|
||||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||
var i, p;
|
||||
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
|
||||
};
|
||||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
||||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
||||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
||||
function fulfill(value) { resume("next", value); }
|
||||
function reject(value) { resume("throw", value); }
|
||||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TabCompleteAction = void 0;
|
||||
const string_argv_1 = __importDefault(require("string-argv"));
|
||||
const BaseClasses_1 = require("../parameters/BaseClasses");
|
||||
const CommandLineChoiceParameter_1 = require("../parameters/CommandLineChoiceParameter");
|
||||
const CommandLineAction_1 = require("./CommandLineAction");
|
||||
const DEFAULT_WORD_TO_AUTOCOMPLETE = '';
|
||||
const DEFAULT_POSITION = 0;
|
||||
class TabCompleteAction extends CommandLineAction_1.CommandLineAction {
|
||||
constructor(actions, globalParameters) {
|
||||
super({
|
||||
actionName: "tab-complete" /* CommandLineConstants.TabCompletionActionName */,
|
||||
summary: 'Provides tab completion.',
|
||||
documentation: 'Provides tab completion.'
|
||||
});
|
||||
this._actions = new Map();
|
||||
for (const action of actions) {
|
||||
const parameterNameToParameterInfoMap = new Map();
|
||||
for (const parameter of action.parameters) {
|
||||
parameterNameToParameterInfoMap.set(parameter.longName, parameter);
|
||||
if (parameter.shortName) {
|
||||
parameterNameToParameterInfoMap.set(parameter.shortName, parameter);
|
||||
}
|
||||
}
|
||||
this._actions.set(action.actionName, parameterNameToParameterInfoMap);
|
||||
}
|
||||
this._globalParameters = new Map();
|
||||
for (const parameter of globalParameters) {
|
||||
this._globalParameters.set(parameter.longName, parameter);
|
||||
if (parameter.shortName) {
|
||||
this._globalParameters.set(parameter.shortName, parameter);
|
||||
}
|
||||
}
|
||||
this._wordToCompleteParameter = this.defineStringParameter({
|
||||
parameterLongName: '--word',
|
||||
argumentName: 'WORD',
|
||||
description: `The word to complete.`,
|
||||
defaultValue: DEFAULT_WORD_TO_AUTOCOMPLETE
|
||||
});
|
||||
this._positionParameter = this.defineIntegerParameter({
|
||||
parameterLongName: '--position',
|
||||
argumentName: 'INDEX',
|
||||
description: `The position in the word to be completed.`,
|
||||
defaultValue: DEFAULT_POSITION
|
||||
});
|
||||
}
|
||||
async onExecute() {
|
||||
var _a, e_1, _b, _c;
|
||||
const commandLine = this._wordToCompleteParameter.value || '';
|
||||
const caretPosition = this._positionParameter.value || (commandLine && commandLine.length) || 0;
|
||||
try {
|
||||
for (var _d = true, _e = __asyncValues(this.getCompletions(commandLine, caretPosition)), _f; _f = await _e.next(), _a = _f.done, !_a;) {
|
||||
_c = _f.value;
|
||||
_d = false;
|
||||
try {
|
||||
const value = _c;
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(value);
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (!_d && !_a && (_b = _e.return)) await _b.call(_e);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
}
|
||||
getCompletions(commandLine, caretPosition = commandLine.length) {
|
||||
return __asyncGenerator(this, arguments, function* getCompletions_1() {
|
||||
const actions = this._actions;
|
||||
if (!commandLine || !caretPosition) {
|
||||
yield __await(yield* __asyncDelegator(__asyncValues(this._getAllActions())));
|
||||
return yield __await(void 0);
|
||||
}
|
||||
const tokens = Array.from(this.tokenizeCommandLine(commandLine));
|
||||
// offset arguments by the number of global params in the input
|
||||
const globalParameterOffset = this._getGlobalParameterOffset(tokens);
|
||||
if (tokens.length < 2 + globalParameterOffset) {
|
||||
yield __await(yield* __asyncDelegator(__asyncValues(this._getAllActions())));
|
||||
return yield __await(void 0);
|
||||
}
|
||||
const lastToken = tokens[tokens.length - 1];
|
||||
const secondLastToken = tokens[tokens.length - 2];
|
||||
const completePartialWord = caretPosition === commandLine.length;
|
||||
if (completePartialWord && tokens.length === 2 + globalParameterOffset) {
|
||||
for (const actionName of actions.keys()) {
|
||||
if (actionName.indexOf(tokens[1 + globalParameterOffset]) === 0) {
|
||||
yield yield __await(actionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (const actionName of actions.keys()) {
|
||||
if (actionName === tokens[1 + globalParameterOffset]) {
|
||||
const parameterNameMap = actions.get(actionName);
|
||||
const parameterNames = Array.from(parameterNameMap.keys());
|
||||
if (completePartialWord) {
|
||||
for (const parameterName of parameterNames) {
|
||||
if (parameterName === secondLastToken) {
|
||||
const values = yield __await(this._getParameterValueCompletions(parameterNameMap.get(parameterName)));
|
||||
if (values.length > 0) {
|
||||
yield __await(yield* __asyncDelegator(__asyncValues(this._completeParameterValues(values, lastToken))));
|
||||
return yield __await(void 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
yield __await(yield* __asyncDelegator(__asyncValues(this._completeParameterValues(parameterNames, lastToken))));
|
||||
}
|
||||
else {
|
||||
for (const parameterName of parameterNames) {
|
||||
if (parameterName === lastToken) {
|
||||
const values = yield __await(this._getParameterValueCompletions(parameterNameMap.get(parameterName)));
|
||||
if (values.length > 0) {
|
||||
yield __await(yield* __asyncDelegator(__asyncValues(values)));
|
||||
return yield __await(void 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const parameterName of parameterNames) {
|
||||
if (parameterName === lastToken &&
|
||||
parameterNameMap.get(parameterName).kind !== BaseClasses_1.CommandLineParameterKind.Flag) {
|
||||
// The parameter is expecting a value, so don't suggest parameter names again
|
||||
return yield __await(void 0);
|
||||
}
|
||||
}
|
||||
yield __await(yield* __asyncDelegator(__asyncValues(parameterNames)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
*_getAllActions() {
|
||||
yield* this._actions.keys();
|
||||
yield* this._globalParameters.keys();
|
||||
}
|
||||
tokenizeCommandLine(commandLine) {
|
||||
return (0, string_argv_1.default)(commandLine);
|
||||
}
|
||||
async _getParameterValueCompletions(parameter) {
|
||||
let choiceParameterValues = [];
|
||||
if (parameter.kind === BaseClasses_1.CommandLineParameterKind.Choice) {
|
||||
choiceParameterValues = parameter.alternatives;
|
||||
}
|
||||
else if (parameter.kind !== BaseClasses_1.CommandLineParameterKind.Flag) {
|
||||
let parameterWithArgumentOrChoices = undefined;
|
||||
if (parameter instanceof BaseClasses_1.CommandLineParameterWithArgument) {
|
||||
parameterWithArgumentOrChoices = parameter;
|
||||
}
|
||||
else if (parameter instanceof CommandLineChoiceParameter_1.CommandLineChoiceParameter) {
|
||||
parameterWithArgumentOrChoices = parameter;
|
||||
}
|
||||
if (parameterWithArgumentOrChoices && parameterWithArgumentOrChoices.completions) {
|
||||
choiceParameterValues = await parameterWithArgumentOrChoices.completions();
|
||||
}
|
||||
}
|
||||
return choiceParameterValues;
|
||||
}
|
||||
_getGlobalParameterOffset(tokens) {
|
||||
const globalParameters = this._globalParameters;
|
||||
let count = 0;
|
||||
outer: for (let i = 1; i < tokens.length; i++) {
|
||||
for (const globalParameter of globalParameters.values()) {
|
||||
if (tokens[i] !== globalParameter.longName && tokens[i] !== globalParameter.shortName) {
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
*_completeParameterValues(choiceParameterValues, lastToken) {
|
||||
for (const choiceParameterValue of choiceParameterValues) {
|
||||
if (choiceParameterValue.indexOf(lastToken) === 0) {
|
||||
yield choiceParameterValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.TabCompleteAction = TabCompleteAction;
|
||||
//# sourceMappingURL=TabCompletionAction.js.map
|
1
node_modules/@rushstack/ts-command-line/lib/providers/TabCompletionAction.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/ts-command-line/lib/providers/TabCompletionAction.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
31
node_modules/@rushstack/ts-command-line/package.json
generated
vendored
Normal file
31
node_modules/@rushstack/ts-command-line/package.json
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "@rushstack/ts-command-line",
|
||||
"version": "4.17.1",
|
||||
"description": "An object-oriented command-line parser for TypeScript",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/microsoft/rushstack.git",
|
||||
"directory": "libraries/ts-command-line"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"typings": "dist/ts-command-line.d.ts",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/argparse": "1.0.38",
|
||||
"argparse": "~1.0.9",
|
||||
"colors": "~1.2.1",
|
||||
"string-argv": "~0.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rushstack/heft": "0.62.0",
|
||||
"@rushstack/heft-node-rig": "2.3.2",
|
||||
"@types/heft-jest": "1.0.1",
|
||||
"@types/node": "18.17.15",
|
||||
"local-eslint-config": "1.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "heft build --clean",
|
||||
"_phase:build": "heft run --only build -- --clean",
|
||||
"_phase:test": "heft run --only test -- --clean"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user