UNPKG

1.87 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google Inc. All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 *
8 */
9import { BaseException, logging } from '@angular-devkit/core';
10import { Arguments, Option } from './interface';
11export declare class ParseArgumentException extends BaseException {
12 readonly comments: string[];
13 readonly parsed: Arguments;
14 readonly ignored: string[];
15 constructor(comments: string[], parsed: Arguments, ignored: string[]);
16}
17/**
18 * Parse the arguments in a consistent way, but without having any option definition. This tries
19 * to assess what the user wants in a free form. For example, using `--name=false` will set the
20 * name properties to a boolean type.
21 * This should only be used when there's no schema available or if a schema is "true" (anything is
22 * valid).
23 *
24 * @param args Argument list to parse.
25 * @returns An object that contains a property per flags from the args.
26 */
27export declare function parseFreeFormArguments(args: string[]): Arguments;
28/**
29 * Parse the arguments in a consistent way, from a list of standardized options.
30 * The result object will have a key per option name, with the `_` key reserved for positional
31 * arguments, and `--` will contain everything that did not match. Any key that don't have an
32 * option will be pushed back in `--` and removed from the object. If you need to validate that
33 * there's no additionalProperties, you need to check the `--` key.
34 *
35 * @param args The argument array to parse.
36 * @param options List of supported options. {@see Option}.
37 * @param logger Logger to use to warn users.
38 * @returns An object that contains a property per option.
39 */
40export declare function parseArguments(args: string[], options: Option[] | null, logger?: logging.Logger): Arguments;