@oclif/core 1.16.6 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/config/config.js
CHANGED
|
@@ -643,6 +643,7 @@ async function toCached(c, plugin) {
|
|
|
643
643
|
allowNo: flag.allowNo,
|
|
644
644
|
dependsOn: flag.dependsOn,
|
|
645
645
|
exclusive: flag.exclusive,
|
|
646
|
+
aliases: flag.aliases,
|
|
646
647
|
};
|
|
647
648
|
}
|
|
648
649
|
else {
|
|
@@ -663,6 +664,7 @@ async function toCached(c, plugin) {
|
|
|
663
664
|
relationships: flag.relationships,
|
|
664
665
|
exclusive: flag.exclusive,
|
|
665
666
|
default: await defaultToCached(flag),
|
|
667
|
+
aliases: flag.aliases,
|
|
666
668
|
};
|
|
667
669
|
// a command-level placeholder in the manifest so that oclif knows it should regenerate the command during help-time
|
|
668
670
|
if (typeof flag.defaultHelp === 'function') {
|
|
@@ -143,6 +143,10 @@ export declare type FlagProps = {
|
|
|
143
143
|
* Define complex relationships between flags.
|
|
144
144
|
*/
|
|
145
145
|
relationships?: Relationship[];
|
|
146
|
+
/**
|
|
147
|
+
* Alternate names that can be used for this flag.
|
|
148
|
+
*/
|
|
149
|
+
aliases?: string[];
|
|
146
150
|
};
|
|
147
151
|
export declare type BooleanFlagProps = FlagProps & {
|
|
148
152
|
type: 'boolean';
|
package/lib/parser/parse.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare class Parser<T extends ParserInput, TFlags extends OutputFlags<T[
|
|
|
4
4
|
private readonly argv;
|
|
5
5
|
private readonly raw;
|
|
6
6
|
private readonly booleanFlags;
|
|
7
|
+
private readonly flagAliases;
|
|
7
8
|
private readonly context;
|
|
8
9
|
private readonly metaData;
|
|
9
10
|
private currentFlag?;
|
package/lib/parser/parse.js
CHANGED
|
@@ -38,6 +38,9 @@ class Parser {
|
|
|
38
38
|
this.argv = [...input.argv];
|
|
39
39
|
this._setNames();
|
|
40
40
|
this.booleanFlags = pickBy(input.flags, f => f.type === 'boolean');
|
|
41
|
+
this.flagAliases = Object.fromEntries(Object.values(input.flags).flatMap(flag => {
|
|
42
|
+
return (flag.aliases ?? []).map(a => [a, flag]);
|
|
43
|
+
}));
|
|
41
44
|
this.metaData = {};
|
|
42
45
|
}
|
|
43
46
|
async parse() {
|
|
@@ -47,6 +50,9 @@ class Parser {
|
|
|
47
50
|
if (this.input.flags[name]) {
|
|
48
51
|
return name;
|
|
49
52
|
}
|
|
53
|
+
if (this.flagAliases[name]) {
|
|
54
|
+
return this.flagAliases[name].name;
|
|
55
|
+
}
|
|
50
56
|
if (arg.startsWith('--no-')) {
|
|
51
57
|
const flag = this.booleanFlags[arg.slice(5)];
|
|
52
58
|
if (flag && flag.allowNo)
|