@trenskow/arguments-parser 0.3.132 → 0.3.134
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/index.js +1 -1
- package/lib/autocomplete/bash.js +3 -1
- package/lib/autocomplete/index.js +8 -7
- package/lib/autocomplete/zsh.js +3 -1
- package/package.json +1 -1
package/index.js
CHANGED
package/lib/autocomplete/bash.js
CHANGED
|
@@ -66,9 +66,11 @@ const bash = (items) => {
|
|
|
66
66
|
bash.script = ({
|
|
67
67
|
command
|
|
68
68
|
}) => `_${command}() {
|
|
69
|
-
|
|
69
|
+
eval "$(AUTOCOMPLETE_INDEX=$COMP_CWORD ${command} "\${COMP_WORDS[@]}")"
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
complete -F _${command} ${command}`;
|
|
73
73
|
|
|
74
|
+
bash.autocompleteIndexOffset = 1;
|
|
75
|
+
|
|
74
76
|
export default bash;
|
|
@@ -27,14 +27,12 @@ const supported = {
|
|
|
27
27
|
|
|
28
28
|
const currentShell = basename(process.env.SHELL || '');
|
|
29
29
|
|
|
30
|
-
const argumentsParser = (
|
|
30
|
+
const argumentsParser = () => {
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const writer = supported[shell || currentShell];
|
|
32
|
+
const writer = supported[currentShell];
|
|
35
33
|
|
|
36
34
|
if (!writer) {
|
|
37
|
-
process.stderr.write(`Unsupported shell: ${
|
|
35
|
+
process.stderr.write(`Unsupported shell: ${currentShell}\n`);
|
|
38
36
|
process.exit(1);
|
|
39
37
|
}
|
|
40
38
|
|
|
@@ -98,11 +96,14 @@ const argumentsParser = (shell) => {
|
|
|
98
96
|
data: {},
|
|
99
97
|
validationOptions: {}
|
|
100
98
|
},
|
|
101
|
-
parameters = {}
|
|
102
|
-
autocompleteIndex = (process.env.AUTOCOMPLETE_INDEX || 2) - 2
|
|
99
|
+
parameters = {}
|
|
103
100
|
} = {}
|
|
104
101
|
) => {
|
|
105
102
|
|
|
103
|
+
let autocompleteIndex = process.env.AUTOCOMPLETE_INDEX;
|
|
104
|
+
|
|
105
|
+
autocompleteIndex = parseInt(autocompleteIndex) - argvLevel - writer.autocompleteIndexOffset;
|
|
106
|
+
|
|
106
107
|
const base = `${process.argv.slice(1, argvLevel + 2).map(((arg) => basename(arg))).join(' ')}`;
|
|
107
108
|
|
|
108
109
|
const next = async (identifier, command) => {
|
package/lib/autocomplete/zsh.js
CHANGED
|
@@ -60,9 +60,11 @@ zsh.script = ({
|
|
|
60
60
|
}) => `#compdef ${command}
|
|
61
61
|
|
|
62
62
|
_${command}() {
|
|
63
|
-
eval "$(
|
|
63
|
+
eval "$(AUTOCOMPLETE_INDEX=$CURRENT ${command} "\${words[@]}")"
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
_${command}`;
|
|
67
67
|
|
|
68
|
+
zsh.autocompleteIndexOffset = 2;
|
|
69
|
+
|
|
68
70
|
export default zsh;
|