clipanion
Advanced tools
Comparing version 4.0.0-rc.1 to 4.0.0-rc.2
@@ -47,2 +47,3 @@ import { NodeType } from './constants'; | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
tokens: Array<Token>; | ||
@@ -85,3 +86,3 @@ }; | ||
to: number; | ||
reducer: "setCandidateState" | "setSelectedIndex" | "pushBatch" | "pushBound" | "pushPath" | "pushPositional" | "pushExtra" | "pushExtraNoLimits" | "pushTrue" | "pushFalse" | "pushUndefined" | "pushStringValue" | "setStringValue" | "inhibateOptions" | "useHelp" | "setError" | "setOptionArityError" | ["setCandidateState" | "setSelectedIndex" | "pushBatch" | "pushBound" | "pushPath" | "pushPositional" | "pushExtra" | "pushExtraNoLimits" | "pushTrue" | "pushFalse" | "pushUndefined" | "pushStringValue" | "setStringValue" | "inhibateOptions" | "useHelp" | "setError" | "setOptionArityError"] | ["setCandidateState" | "setSelectedIndex" | "pushBatch" | "pushBound" | "pushPath" | "pushPositional" | "pushExtra" | "pushExtraNoLimits" | "pushTrue" | "pushFalse" | "pushUndefined" | "pushStringValue" | "setStringValue" | "inhibateOptions" | "useHelp" | "setError" | "setOptionArityError", Partial<RunState>] | ["setCandidateState" | "setSelectedIndex" | "pushBatch" | "pushBound" | "pushPath" | "pushPositional" | "pushExtra" | "pushExtraNoLimits" | "pushTrue" | "pushFalse" | "pushUndefined" | "pushStringValue" | "setStringValue" | "inhibateOptions" | "useHelp" | "setError" | "setOptionArityError", number] | ["setCandidateState" | "setSelectedIndex" | "pushBatch" | "pushBound" | "pushPath" | "pushPositional" | "pushExtra" | "pushExtraNoLimits" | "pushTrue" | "pushFalse" | "pushUndefined" | "pushStringValue" | "setStringValue" | "inhibateOptions" | "useHelp" | "setError" | "setOptionArityError", Map<string, string>] | ["setCandidateState" | "setSelectedIndex" | "pushBatch" | "pushBound" | "pushPath" | "pushPositional" | "pushExtra" | "pushExtraNoLimits" | "pushTrue" | "pushFalse" | "pushUndefined" | "pushStringValue" | "setStringValue" | "inhibateOptions" | "useHelp" | "setError" | "setOptionArityError", string] | undefined; | ||
reducer: "setCandidateState" | "setSelectedIndex" | "setPartialIndex" | "pushBatch" | "pushBound" | "pushPath" | "pushPositional" | "pushExtra" | "pushExtraNoLimits" | "pushTrue" | "pushFalse" | "pushUndefined" | "pushStringValue" | "setStringValue" | "inhibateOptions" | "useHelp" | "setError" | "setOptionArityError" | ["setCandidateState" | "setSelectedIndex" | "setPartialIndex" | "pushBatch" | "pushBound" | "pushPath" | "pushPositional" | "pushExtra" | "pushExtraNoLimits" | "pushTrue" | "pushFalse" | "pushUndefined" | "pushStringValue" | "setStringValue" | "inhibateOptions" | "useHelp" | "setError" | "setOptionArityError"] | ["setCandidateState" | "setSelectedIndex" | "setPartialIndex" | "pushBatch" | "pushBound" | "pushPath" | "pushPositional" | "pushExtra" | "pushExtraNoLimits" | "pushTrue" | "pushFalse" | "pushUndefined" | "pushStringValue" | "setStringValue" | "inhibateOptions" | "useHelp" | "setError" | "setOptionArityError", Partial<RunState>] | ["setCandidateState" | "setSelectedIndex" | "setPartialIndex" | "pushBatch" | "pushBound" | "pushPath" | "pushPositional" | "pushExtra" | "pushExtraNoLimits" | "pushTrue" | "pushFalse" | "pushUndefined" | "pushStringValue" | "setStringValue" | "inhibateOptions" | "useHelp" | "setError" | "setOptionArityError", number] | ["setCandidateState" | "setSelectedIndex" | "setPartialIndex" | "pushBatch" | "pushBound" | "pushPath" | "pushPositional" | "pushExtra" | "pushExtraNoLimits" | "pushTrue" | "pushFalse" | "pushUndefined" | "pushStringValue" | "setStringValue" | "inhibateOptions" | "useHelp" | "setError" | "setOptionArityError", Map<string, string>] | ["setCandidateState" | "setSelectedIndex" | "setPartialIndex" | "pushBatch" | "pushBound" | "pushPath" | "pushPositional" | "pushExtra" | "pushExtraNoLimits" | "pushTrue" | "pushFalse" | "pushUndefined" | "pushStringValue" | "setStringValue" | "inhibateOptions" | "useHelp" | "setError" | "setOptionArityError", string] | undefined; | ||
}; | ||
@@ -133,2 +134,3 @@ export declare function cloneNode(input: Node, offset?: number): Node; | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
tokens: Array<Token>; | ||
@@ -152,4 +154,24 @@ }; | ||
remainder: string | null; | ||
partial: boolean; | ||
tokens: Array<Token>; | ||
}; | ||
setPartialIndex: (state: RunState, segment: string, segmentIndex: number, index: number) => { | ||
selectedIndex: number; | ||
partial: boolean; | ||
candidateUsage: string | null; | ||
requiredOptions: Array<Array<string>>; | ||
errorMessage: string | null; | ||
ignoreOptions: boolean; | ||
options: Array<{ | ||
name: string; | ||
value: any; | ||
}>; | ||
path: Array<string>; | ||
positionals: Array<{ | ||
value: string; | ||
extra: boolean | typeof NoLimits; | ||
}>; | ||
remainder: string | null; | ||
tokens: Array<Token>; | ||
}; | ||
pushBatch: (state: RunState, segment: string, segmentIndex: number, names: Map<string, string>) => { | ||
@@ -172,2 +194,3 @@ options: { | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
}; | ||
@@ -191,2 +214,3 @@ pushBound: (state: RunState, segment: string, segmentIndex: number) => { | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
}; | ||
@@ -210,2 +234,3 @@ pushPath: (state: RunState, segment: string, segmentIndex: number) => { | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
}; | ||
@@ -229,2 +254,3 @@ pushPositional: (state: RunState, segment: string, segmentIndex: number) => { | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
}; | ||
@@ -248,2 +274,3 @@ pushExtra: (state: RunState, segment: string, segmentIndex: number) => { | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
}; | ||
@@ -267,2 +294,3 @@ pushExtraNoLimits: (state: RunState, segment: string, segmentIndex: number) => { | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
}; | ||
@@ -286,2 +314,3 @@ pushTrue: (state: RunState, segment: string, segmentIndex: number, name: string) => { | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
}; | ||
@@ -305,2 +334,3 @@ pushFalse: (state: RunState, segment: string, segmentIndex: number, name: string) => { | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
}; | ||
@@ -324,2 +354,3 @@ pushUndefined: (state: RunState, segment: string, segmentIndex: number, name: string) => { | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
}; | ||
@@ -343,2 +374,3 @@ pushStringValue: (state: RunState, segment: string, segmentIndex: number) => { | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
}; | ||
@@ -362,2 +394,3 @@ setStringValue: (state: RunState, segment: string, segmentIndex: number) => { | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
}; | ||
@@ -380,2 +413,3 @@ inhibateOptions: (state: RunState) => { | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
tokens: Array<Token>; | ||
@@ -399,2 +433,3 @@ }; | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
tokens: Array<Token>; | ||
@@ -418,2 +453,3 @@ }; | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
tokens: Array<Token>; | ||
@@ -437,2 +473,3 @@ }; | ||
selectedIndex: number | null; | ||
partial: boolean; | ||
tokens: Array<Token>; | ||
@@ -439,0 +476,0 @@ }; |
@@ -24,2 +24,3 @@ 'use strict'; | ||
selectedIndex: constants.HELP_COMMAND_INDEX, | ||
partial: false, | ||
tokens: [], | ||
@@ -118,2 +119,3 @@ }; | ||
selectedIndex: null, | ||
partial: false, | ||
tokens: [], | ||
@@ -231,5 +233,10 @@ }, | ||
function selectBestState(input, states) { | ||
const terminalStates = states.filter(state => { | ||
let terminalStates = states.filter(state => { | ||
return state.selectedIndex !== null; | ||
}); | ||
const noPartialStates = terminalStates.filter(state => { | ||
return !state.partial; | ||
}); | ||
if (noPartialStates.length > 0) | ||
terminalStates = noPartialStates; | ||
if (terminalStates.length === 0) | ||
@@ -395,2 +402,5 @@ throw new Error(); | ||
}, | ||
setPartialIndex: (state, segment, segmentIndex, index) => { | ||
return { ...state, selectedIndex: index, partial: true }; | ||
}, | ||
pushBatch: (state, segment, segmentIndex, names) => { | ||
@@ -626,3 +636,3 @@ const options = state.options.slice(); | ||
registerStatic(machine, lastPathNode, constants.SpecialToken.EndOfInput, constants.NodeType.ErrorNode, [`setError`, `Not enough positional arguments`]); | ||
registerStatic(machine, lastPathNode, constants.SpecialToken.EndOfPartialInput, constants.NodeType.SuccessNode, [`setSelectedIndex`, this.cliIndex]); | ||
registerStatic(machine, lastPathNode, constants.SpecialToken.EndOfPartialInput, constants.NodeType.SuccessNode, [`setPartialIndex`, this.cliIndex]); | ||
} | ||
@@ -636,3 +646,3 @@ let lastLeadingNode = lastPathNode; | ||
registerStatic(machine, nextLeadingNode, constants.SpecialToken.EndOfInput, constants.NodeType.ErrorNode, [`setError`, `Not enough positional arguments`]); | ||
registerStatic(machine, nextLeadingNode, constants.SpecialToken.EndOfPartialInput, constants.NodeType.SuccessNode, [`setSelectedIndex`, this.cliIndex]); | ||
registerStatic(machine, nextLeadingNode, constants.SpecialToken.EndOfPartialInput, constants.NodeType.SuccessNode, [`setPartialIndex`, this.cliIndex]); | ||
} | ||
@@ -668,3 +678,3 @@ registerDynamic(machine, lastLeadingNode, `isNotOptionLike`, nextLeadingNode, `pushPositional`); | ||
registerStatic(machine, lastExtraNode, constants.SpecialToken.EndOfInput, constants.NodeType.ErrorNode, [`setError`, `Not enough positional arguments`]); | ||
registerStatic(machine, lastExtraNode, constants.SpecialToken.EndOfPartialInput, constants.NodeType.SuccessNode, [`setSelectedIndex`, this.cliIndex]); | ||
registerStatic(machine, lastExtraNode, constants.SpecialToken.EndOfPartialInput, constants.NodeType.SuccessNode, [`setPartialIndex`, this.cliIndex]); | ||
} | ||
@@ -678,3 +688,3 @@ let lastTrailingNode = lastExtraNode; | ||
registerStatic(machine, nextTrailingNode, constants.SpecialToken.EndOfInput, constants.NodeType.ErrorNode, [`setError`, `Not enough positional arguments`]); | ||
registerStatic(machine, nextTrailingNode, constants.SpecialToken.EndOfPartialInput, constants.NodeType.SuccessNode, [`setSelectedIndex`, this.cliIndex]); | ||
registerStatic(machine, nextTrailingNode, constants.SpecialToken.EndOfPartialInput, constants.NodeType.SuccessNode, [`setPartialIndex`, this.cliIndex]); | ||
} | ||
@@ -681,0 +691,0 @@ registerDynamic(machine, lastTrailingNode, `isNotOptionLike`, nextTrailingNode, `pushPositional`); |
@@ -15,3 +15,3 @@ { | ||
], | ||
"version": "4.0.0-rc.1", | ||
"version": "4.0.0-rc.2", | ||
"main": "lib/advanced/index", | ||
@@ -18,0 +18,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
232863
5326
8