fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Johannes AltmanningerMerge pull request #1178201d7f9391

master
52.9 KiB732 linesraw
1# npm (https://npmjs.org) completions for Fish shell
2# __fish_npm_needs_* and __fish_npm_using_* taken from:
3# https://stackoverflow.com/questions/16657803/creating-autocomplete-script-with-sub-commands
4# see also Fish's large set of completions for examples:
5# https://github.com/fish-shell/fish-shell/tree/master/share/completions
6
7__fish_npm_helper
8set -l npm_install "npm install --global"
9
10function __fish_npm_needs_command
11    set -l cmd (commandline -xpc)
12
13    if test (count $cmd) -eq 1
14        return 0
15    end
16
17    return 1
18end
19
20function __fish_npm_using_command
21    set -l cmd (commandline -xpc)
22
23    if test (count $cmd) -gt 1
24        if contains -- $cmd[2] $argv
25            return 0
26        end
27    end
28
29    return 1
30end
31
32function __fish_npm_needs_option
33    switch (commandline -ct)
34        case "-*"
35            return 0
36    end
37    return 1
38end
39
40# list available npm scripts and their partial content
41function __fish_parse_npm_run_completions
42    while read -l name
43        set -l trim 20
44        read -l value
45        set value (string sub -l $trim -- $value)
46        printf "%s\t%s\n" $name $value
47    end
48end
49
50function __fish_npm_run
51    # Complete `npm run` scripts
52    # These are stored in package.json, which we need a tool to read.
53    # python is very probably installed (we use it for other things!),
54    # jq is slower but also a common tool,
55    # npm is dog-slow and might check for updates online!
56    if test -e package.json; and set -l python (__fish_anypython)
57        # Warning: That weird indentation is necessary, because python.
58        $python -S -c 'import json, sys; data = json.load(sys.stdin);
59for k,v in data["scripts"].items(): print(k + "\t" + v[:18])' <package.json 2>/dev/null
60    else if command -sq jq; and test -e package.json
61        jq -r '.scripts | to_entries | map("\(.key)\t\(.value | tostring | .[0:20])") | .[]' package.json
62    else if command -sq npm
63        # Like above, only try to call npm if there's a command by that name to facilitate aliases that call nvm.
64        command npm run | string match -r -v '^[^ ]|^$' | string trim | __fish_parse_npm_run_completions
65    end
66end
67
68# run
69complete -f -c npm -n __fish_npm_needs_command -a 'run-script run' -d 'Run arbitrary package scripts'
70for c in run-script run rum urn
71    complete -f -c npm -n "__fish_npm_using_command $c" -a "(__fish_npm_run)"
72    complete -f -c npm -n "__fish_npm_using_command $c" -l if-present -d "Don't error on nonexistent script"
73    complete -f -c npm -n "__fish_npm_using_command $c" -l ignore-scripts -d "Don't run pre-, post- and life-cycle scripts"
74    complete -x -c npm -n "__fish_npm_using_command $c" -s script-shell -d 'The shell to use for scripts'
75    complete -f -c npm -n "__fish_npm_using_command $c" -l foreground-scripts -d 'Run all build scripts in the foreground'
76end
77
78# access
79set -l access_commands 'list get set grant revoke'
80complete -f -c npm -n __fish_npm_needs_command -a access -d 'Set access level on published packages'
81complete -x -c npm -n '__fish_npm_using_command access' -n "not __fish_seen_subcommand_from $access_commands" -a list -d 'List access info'
82complete -x -c npm -n '__fish_npm_using_command access' -n "not __fish_seen_subcommand_from $access_commands" -a get -d 'Get access level'
83complete -x -c npm -n '__fish_npm_using_command access' -n "not __fish_seen_subcommand_from $access_commands" -a grant -d 'Grant access to users'
84complete -x -c npm -n '__fish_npm_using_command access' -n "not __fish_seen_subcommand_from $access_commands" -a revoke -d 'Revoke access from users'
85complete -x -c npm -n '__fish_npm_using_command access' -n "not __fish_seen_subcommand_from $access_commands" -a set -d 'Set access level'
86complete -x -c npm -n '__fish_npm_using_command access' -n '__fish_seen_subcommand_from list' -a 'packages collaborators'
87complete -x -c npm -n '__fish_npm_using_command access' -n '__fish_seen_subcommand_from get' -a status
88complete -x -c npm -n '__fish_npm_using_command access' -n '__fish_seen_subcommand_from grant' -a 'read-only read-write'
89complete -x -c npm -n '__fish_npm_using_command access' -n '__fish_seen_subcommand_from set' -a 'status=public status=private' -d 'Set package status'
90complete -x -c npm -n '__fish_npm_using_command access' -n '__fish_seen_subcommand_from set' -a 'mfa=none mfa=publish mfa=automation' -d 'Set package MFA'
91complete -x -c npm -n '__fish_npm_using_command access' -n '__fish_seen_subcommand_from set' -a '2fa=none 2fa=publish 2fa=automation' -d 'Set package MFA'
92complete -f -c npm -n '__fish_npm_using_command access' -l json -d 'Output JSON'
93complete -x -c npm -n '__fish_npm_using_command access' -l otp -d '2FA one-time password'
94complete -x -c npm -n '__fish_npm_using_command access' -l registry -d 'Registry base URL'
95complete -f -c npm -n '__fish_npm_using_command access' -s h -l help -d 'Display help'
96
97# adduser
98complete -f -c npm -n __fish_npm_needs_command -a adduser -d 'Add a registry user account'
99complete -f -c npm -n __fish_npm_needs_command -a login -d 'Login to a registry user account'
100for c in adduser add-user login
101    complete -x -c npm -n "__fish_npm_using_command $c" -l registry -d 'Registry base URL'
102    complete -x -c npm -n "__fish_npm_using_command $c" -l scope -d 'Log into a private repository'
103    complete -x -c npm -n "__fish_npm_using_command $c" -l auth-type -a 'legacy web' -d 'Authentication strategy'
104    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
105end
106
107# audit
108complete -f -c npm -n __fish_npm_needs_command -a audit -d 'Run a security audit'
109complete -f -c npm -n '__fish_npm_using_command audit' -a signatures -d 'Verify registry signatures'
110complete -f -c npm -n '__fish_npm_using_command audit' -a fix -d 'Install compatible updates to vulnerable deps'
111complete -x -c npm -n '__fish_npm_using_command audit' -l audit-level -a 'info low moderate high critical none' -d 'Audit level'
112complete -f -c npm -n '__fish_npm_using_command audit' -l dry-run -d 'Do not make any changes'
113complete -f -c npm -n '__fish_npm_using_command audit' -s f -l force -d 'Removes various protections'
114complete -f -c npm -n '__fish_npm_using_command audit' -l json -d 'Output JSON'
115complete -f -c npm -n '__fish_npm_using_command audit' -l package-lock-only -d 'Only use package-lock.json, ignore node_modules'
116complete -x -c npm -n '__fish_npm_using_command audit' -l omit -a 'dev optional peer' -d 'Omit dependency type'
117complete -f -c npm -n '__fish_npm_using_command audit' -l foreground-scripts -d 'Run all build scripts in the foreground'
118complete -f -c npm -n '__fish_npm_using_command audit' -l ignore-scripts -d "Don't run pre-, post- and life-cycle scripts"
119complete -f -c npm -n '__fish_npm_using_command audit' -l install-links -d 'Install file: protocol deps as regular deps'
120complete -f -c npm -n '__fish_npm_using_command audit' -s h -l help -d 'Display help'
121
122# bugs
123for c in bugs issues
124    complete -f -c npm -n __fish_npm_needs_command -a "$c" -d 'Report bugs for a package in a web browser'
125    complete -x -c npm -n "__fish_npm_using_command $c" -l browser -d 'Set browser'
126    complete -x -c npm -n "__fish_npm_using_command $c" -l no-browser -d 'Print to stdout'
127    complete -x -c npm -n "__fish_npm_using_command $c" -l registry -d 'Registry base URL'
128    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
129end
130
131# cache
132complete -f -c npm -n __fish_npm_needs_command -a cache -d "Manipulates package's cache"
133complete -f -c npm -n '__fish_npm_using_command cache' -a add -d 'Add the specified package to the local cache'
134complete -f -c npm -n '__fish_npm_using_command cache' -a clean -d 'Delete data out of the cache folder'
135complete -f -c npm -n '__fish_npm_using_command cache' -a ls -d 'Show the data in the cache'
136complete -f -c npm -n '__fish_npm_using_command cache' -a verify -d 'Verify the contents of the cache folder'
137complete -x -c npm -n '__fish_npm_using_command cache' -l cache -a '(__fish_complete_directories)' -d 'Cache location'
138complete -f -c npm -n '__fish_npm_using_command cache' -s h -l help -d 'Display help'
139
140# ci
141# install-ci-test
142complete -f -c npm -n __fish_npm_needs_command -a 'ci clean-install' -d 'Clean install a project'
143complete -f -c npm -n __fish_npm_needs_command -a 'install-ci-test cit' -d 'Install a project with a clean slate and run tests'
144# typos are intentional
145for c in ci clean-install ic install-clean isntall-clean install-ci-test cit clean-install-test sit
146    complete -x -c npm -n "__fish_npm_using_command $c" -l install-strategy -a 'hoisted nested shallow linked' -d 'Install strategy'
147    complete -x -c npm -n "__fish_npm_using_command $c" -l omit -a 'dev optional peer' -d 'Omit dependency type'
148    complete -x -c npm -n "__fish_npm_using_command $c" -l strict-peer-deps -d 'Treat conflicting peerDependencies as failure'
149    complete -f -c npm -n "__fish_npm_using_command $c" -l foreground-scripts -d 'Run all build scripts in the foreground'
150    complete -f -c npm -n "__fish_npm_using_command $c" -l ignore-scripts -d "Don't run pre-, post- and life-cycle scripts"
151    complete -f -c npm -n "__fish_npm_using_command $c" -l no-audit -d "Don't submit audit reports"
152    complete -f -c npm -n "__fish_npm_using_command $c" -l no-bin-links -d "Don't symblink package executables"
153    complete -f -c npm -n "__fish_npm_using_command $c" -l no-fund -d "Don't display funding info"
154    complete -f -c npm -n "__fish_npm_using_command $c" -l dry-run -d 'Do not make any changes'
155    complete -f -c npm -n "__fish_npm_using_command $c" -l install-links -d 'Install file: protocol deps as regular deps'
156    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
157end
158
159# completion
160complete -f -c npm -n __fish_npm_needs_command -a completion -d 'Tab Completion for npm'
161complete -f -c npm -n '__fish_npm_using_command completion' -s h -l help -d 'Display help'
162
163# config
164complete -f -c npm -n __fish_npm_needs_command -a config -d 'Manage the npm configuration files'
165for c in config c
166    set -l config_commands 'set get delete list edit fix'
167    complete -x -c npm -n "__fish_npm_using_command $c" -n "not __fish_seen_subcommand_from $config_commands" -a set -d 'Sets the config keys to the values'
168    complete -x -c npm -n "__fish_npm_using_command $c" -n "not __fish_seen_subcommand_from $config_commands" -a get -d 'Echo the config value(s) to stdout'
169    complete -x -c npm -n "__fish_npm_using_command $c" -n "not __fish_seen_subcommand_from $config_commands" -a delete -d 'Deletes the key from all config files'
170    complete -x -c npm -n "__fish_npm_using_command $c" -n "not __fish_seen_subcommand_from $config_commands" -a list -d 'Show all config settings'
171    complete -x -c npm -n "__fish_npm_using_command $c" -n "not __fish_seen_subcommand_from $config_commands" -a edit -d 'Opens the config file in an editor'
172    complete -x -c npm -n "__fish_npm_using_command $c" -n "not __fish_seen_subcommand_from $config_commands" -a fix -d 'Attempts to repair invalid config items'
173    complete -f -c npm -n "__fish_npm_using_command $c" -l json -d 'Output JSON'
174    complete -f -c npm -n "__fish_npm_using_command $c" -s g -l global -d 'Edit global config'
175    complete -x -c npm -n "__fish_npm_using_command $c" -l editor -d 'Specify the editor'
176    complete -x -c npm -n "__fish_npm_using_command $c" -s L -l location -a 'global user project' -d 'Which config file'
177    complete -f -c npm -n "__fish_npm_using_command $c" -s l -l long -d 'Show extended information'
178    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
179end
180# get, set also exist as shorthands
181complete -f -c npm -n __fish_npm_needs_command -a get -d 'Get a value from the npm configuration'
182complete -f -c npm -n '__fish_npm_using_command get' -s l -l long -d 'Show extended information'
183complete -f -c npm -n '__fish_npm_using_command get' -s h -l help -d 'Display help'
184# set
185complete -f -c npm -n __fish_npm_needs_command -a set -d 'Set a value in the npm configuration'
186complete -x -c npm -n '__fish_npm_using_command set' -s L -l location -a 'global user project' -d 'Which config file'
187complete -f -c npm -n '__fish_npm_using_command set' -s g -l global -d 'Edit global config'
188complete -f -c npm -n '__fish_npm_using_command set' -s h -l help -d 'Display help'
189
190# dedupe
191complete -f -c npm -n __fish_npm_needs_command -a dedupe -d 'Reduce duplication'
192complete -f -c npm -n __fish_npm_needs_command -a find-dupes -d 'Find duplication'
193for c in dedupe ddp find-dupes
194    complete -x -c npm -n "__fish_npm_using_command $c" -l install-strategy -a 'hoisted nested shallow linked' -d 'Install strategy'
195    complete -x -c npm -n "__fish_npm_using_command $c" -l strict-peer-deps -d 'Treat conflicting peerDependencies as failure'
196    complete -x -c npm -n "__fish_npm_using_command $c" -l no-package-lock -d 'Ignore package-lock.json'
197    complete -x -c npm -n "__fish_npm_using_command $c" -l omit -a 'dev optional peer' -d 'Omit dependency type'
198    complete -f -c npm -n "__fish_npm_using_command $c" -l ignore-scripts -d "Don't run pre-, post- and life-cycle scripts"
199    complete -f -c npm -n "__fish_npm_using_command $c" -l no-audit -d "Don't submit audit reports"
200    complete -f -c npm -n "__fish_npm_using_command $c" -l no-bin-links -d "Don't symblink package executables"
201    complete -f -c npm -n "__fish_npm_using_command $c" -l no-fund -d "Don't display funding info"
202    complete -f -c npm -n "__fish_npm_using_command $c" -l install-links -d 'Install file: protocol deps as regular deps'
203    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
204
205    if test $c != find-dupes
206        complete -f -c npm -n "__fish_npm_using_command $c" -l dry-run -d "Don't display funding info"
207    end
208end
209
210# deprecate
211complete -f -c npm -n __fish_npm_needs_command -a deprecate -d 'Deprecate a version of a package'
212complete -x -c npm -n '__fish_npm_using_command deprecate' -l registry -d 'Registry base URL'
213complete -x -c npm -n '__fish_npm_using_command deprecate' -l otp -d '2FA one-time password'
214complete -f -c npm -n '__fish_npm_using_command deprecate' -s h -l help -d 'Display help'
215
216# diff
217complete -f -c npm -n __fish_npm_needs_command -a diff -d 'The registry diff command'
218complete -x -c npm -n '__fish_npm_using_command diff' -l diff -d 'Arguments to compare'
219complete -f -c npm -n '__fish_npm_using_command diff' -l diff-name-only -d 'Prints only filenames'
220complete -x -c npm -n '__fish_npm_using_command diff' -l diff-unified -d 'The number of lines to print'
221complete -f -c npm -n '__fish_npm_using_command diff' -l diff-ignore-all-space -d 'Ignore whitespace'
222complete -f -c npm -n '__fish_npm_using_command diff' -l diff-no-prefix -d 'Do not show any prefix'
223complete -x -c npm -n '__fish_npm_using_command diff' -l diff-src-prefix -d 'Source prefix'
224complete -x -c npm -n '__fish_npm_using_command diff' -l diff-dst-prefix -d 'Destination prefix'
225complete -f -c npm -n '__fish_npm_using_command diff' -l diff-text -d 'Treat all files as text'
226complete -f -c npm -n '__fish_npm_using_command diff' -s g -l global -d 'Operates in "global" mode'
227complete -x -c npm -n '__fish_npm_using_command diff' -l tag -d 'The tag used to fetch the tarball'
228complete -f -c npm -n '__fish_npm_using_command diff' -s h -l help -d 'Display help'
229
230# dist-tag
231complete -f -c npm -n __fish_npm_needs_command -a dist-tag -d 'Modify package distribution tags'
232for c in dist-tag dist-tags
233    complete -f -c npm -n "__fish_npm_using_command $c" -a add -d 'Tag the package'
234    complete -f -c npm -n "__fish_npm_using_command $c" -a rm -d 'Clear a tag from the package'
235    complete -f -c npm -n "__fish_npm_using_command $c" -a ls -d 'List all dist-tags'
236    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
237end
238
239# docs
240complete -f -c npm -n __fish_npm_needs_command -a docs -d 'Open docs for a package in a web browser'
241for c in docs home
242    complete -x -c npm -n "__fish_npm_using_command $c" -l browser -d 'Set browser'
243    complete -x -c npm -n "__fish_npm_using_command $c" -l registry -d 'Registry base URL'
244    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
245end
246
247# doctor
248complete -f -c npm -n __fish_npm_needs_command -a doctor -d 'Check your npm environment'
249complete -f -c npm -n '__fish_npm_using_command doctor' -a ping -d 'Check npm ping'
250complete -f -c npm -n '__fish_npm_using_command doctor' -a registry -d 'Check registry'
251complete -f -c npm -n '__fish_npm_using_command doctor' -a versions -d 'Check installed versions'
252complete -f -c npm -n '__fish_npm_using_command doctor' -a environment -d 'Check PATH'
253complete -f -c npm -n '__fish_npm_using_command doctor' -a permissions -d 'Check file permissions'
254complete -f -c npm -n '__fish_npm_using_command doctor' -a cache -d 'Verify cache'
255complete -f -c npm -n '__fish_npm_using_command doctor' -s h -l help -d 'Display help'
256
257# edit
258complete -f -c npm -n __fish_npm_needs_command -a edit -d 'Edit an installed package'
259complete -f -c npm -n '__fish_npm_using_command edit' -l editor -d 'Specify the editor'
260complete -f -c npm -n '__fish_npm_using_command edit' -s h -l help -d 'Display help'
261
262# exec
263complete -f -c npm -n __fish_npm_needs_command -a exec -d 'Run a command from a local or remote npm package'
264for c in exec x
265    complete -x -c npm -n "__fish_npm_using_command $c" -l package -d 'The package(s) to install'
266    complete -x -c npm -n "__fish_npm_using_command $c" -l call -d 'Specify a custom command'
267    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
268end
269
270# explain
271for c in explain why
272    complete -f -c npm -n __fish_npm_needs_command -a "$c" -d 'Explain installed packages'
273    complete -f -c npm -n "__fish_npm_using_command $c" -l json -d 'Output JSON'
274    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
275end
276
277# explore
278complete -f -c npm -n __fish_npm_needs_command -a explore -d 'Browse an installed package'
279complete -f -c npm -n '__fish_npm_using_command explore' -a shell -d 'The shell to open'
280complete -f -c npm -n '__fish_npm_using_command explore' -s h -l help -d 'Display help'
281
282# fund
283complete -f -c npm -n __fish_npm_needs_command -a fund -d 'Retrieve funding information'
284complete -f -c npm -n '__fish_npm_using_command fund' -l json -d 'Output JSON'
285complete -x -c npm -n '__fish_npm_using_command fund' -l browser -d 'Set browser'
286complete -f -c npm -n '__fish_npm_using_command fund' -l no-browser -d 'Print to stdout'
287complete -f -c npm -n '__fish_npm_using_command fund' -l unicode -d 'Use unicode characters in the output'
288complete -f -c npm -n '__fish_npm_using_command fund' -l no-unicode -d 'Use ascii characters over unicode glyphs'
289complete -x -c npm -n '__fish_npm_using_command fund' -l which -d 'Which source URL to open (1-indexed)'
290complete -f -c npm -n '__fish_npm_using_command fund' -s h -l help -d 'Display help'
291
292# help
293complete -f -c npm -n __fish_npm_needs_command -a help -d 'Get help on npm'
294for c in help hlep
295    complete -f -c npm -n "__fish_npm_using_command $c" -l viewer -a 'browser man' -d 'Program to view content'
296    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
297    complete -f -c npm -n "__fish_npm_using_command $c" -a registry -d 'The JavaScript Package Registry'
298    complete -f -c npm -n "__fish_npm_using_command $c" -a removal -d 'Cleaning the Slate'
299    complete -f -c npm -n "__fish_npm_using_command $c" -a logging -d 'Why, What & How We Log'
300    complete -f -c npm -n "__fish_npm_using_command $c" -a scope -d 'How npm handles the "scripts" field'
301    complete -f -c npm -n "__fish_npm_using_command $c" -a dependency-selectors -d 'Dependency Selector Syntax & Querying'
302    complete -f -c npm -n "__fish_npm_using_command $c" -a npm -d 'javascript package manager'
303    complete -f -c npm -n "__fish_npm_using_command $c" -a npmrc -d 'The npm config files'
304    complete -f -c npm -n "__fish_npm_using_command $c" -a shrinkwrap -d 'A publishable lockfile'
305    complete -f -c npm -n "__fish_npm_using_command $c" -a developers -d 'Developer Guide'
306    complete -f -c npm -n "__fish_npm_using_command $c" -a npx -d 'Run a command from a local or remote npm package'
307    complete -f -c npm -n "__fish_npm_using_command $c" -a package-json -d "Specifics of npm's package.json handling"
308    complete -f -c npm -n "__fish_npm_using_command $c" -a package-lock-json -d 'A manifestation of the manifest'
309    complete -f -c npm -n "__fish_npm_using_command $c" -a package-spec -d 'Package name specifier'
310    complete -f -c npm -n "__fish_npm_using_command $c" -a folders -d 'Folder Structures Used by npm'
311    complete -f -c npm -n "__fish_npm_using_command $c" -a global -d 'Folder Structures Used by npm'
312    complete -f -c npm -n "__fish_npm_using_command $c" -a workspaces -d 'FolderWorking with workspaces'
313    complete -f -c npm -n "__fish_npm_using_command $c" -a 'run-script run' -d 'Run arbitrary package scripts'
314    complete -f -c npm -n "__fish_npm_using_command $c" -a access -d 'Set access level on published packages'
315    complete -f -c npm -n "__fish_npm_using_command $c" -a adduser -d 'Add a registry user account'
316    complete -f -c npm -n "__fish_npm_using_command $c" -a login -d 'Login to a registry user account'
317    complete -f -c npm -n "__fish_npm_using_command $c" -a audit -d 'Run a security audit'
318    complete -f -c npm -n "__fish_npm_using_command $c" -a 'bugs issues' -d 'Report bugs for a package in a web browser'
319    complete -f -c npm -n "__fish_npm_using_command $c" -a cache -d "Manipulates package's cache"
320    complete -f -c npm -n "__fish_npm_using_command $c" -a 'ci clean-install' -d 'Clean install a project'
321    complete -f -c npm -n "__fish_npm_using_command $c" -a 'install-ci-test cit' -d 'Install a project with a clean slate and run tests'
322    complete -f -c npm -n "__fish_npm_using_command $c" -a config -d 'Manage the npm configuration files'
323    complete -f -c npm -n "__fish_npm_using_command $c" -a dedupe -d 'Reduce duplication'
324    complete -f -c npm -n "__fish_npm_using_command $c" -a find-dupes -d 'Find duplication'
325    complete -f -c npm -n "__fish_npm_using_command $c" -a deprecate -d 'Deprecate a version of a package'
326    complete -f -c npm -n "__fish_npm_using_command $c" -a diff -d 'The registry diff command'
327    complete -f -c npm -n "__fish_npm_using_command $c" -a dist-tag -d 'Modify package distribution tags'
328    complete -f -c npm -n "__fish_npm_using_command $c" -a docs -d 'Open docs for a package in a web browser'
329    complete -f -c npm -n "__fish_npm_using_command $c" -a doctor -d 'Check your npm environment'
330    complete -f -c npm -n "__fish_npm_using_command $c" -a edit -d 'Edit an installed package'
331    complete -f -c npm -n "__fish_npm_using_command $c" -a exec -d 'Run a command from a local or remote npm package'
332    complete -f -c npm -n "__fish_npm_using_command $c" -a 'explaiin why' -d 'Explain installed packages'
333    complete -f -c npm -n "__fish_npm_using_command $c" -a explore -d 'Browse an installed package'
334    complete -f -c npm -n "__fish_npm_using_command $c" -a fund -d 'Retrieve funding information'
335    complete -f -c npm -n "__fish_npm_using_command $c" -a help -d 'Get help on npm'
336    complete -f -c npm -n "__fish_npm_using_command $c" -a help-search -d 'Search npm help documentation'
337    complete -f -c npm -n "__fish_npm_using_command $c" -a hook -d 'Manage registry hooks'
338    complete -f -c npm -n "__fish_npm_using_command $c" -a 'init create' -d 'Create a package.json file'
339    complete -f -c npm -n "__fish_npm_using_command $c" -a 'install add i' -d 'Install a package'
340    complete -f -c npm -n "__fish_npm_using_command $c" -a 'install-test it' -d 'Install package(s) and run tests'
341    complete -f -c npm -n "__fish_npm_using_command $c" -a logout -d 'Log out of the registry'
342    complete -f -c npm -n "__fish_npm_using_command $c" -a 'ls list' -d 'List installed packages'
343    complete -f -c npm -n "__fish_npm_using_command $c" -a outdated -d 'Check for outdated packages'
344    complete -f -c npm -n "__fish_npm_using_command $c" -a org -d 'Manage orgs'
345    complete -f -c npm -n "__fish_npm_using_command $c" -a 'owner author' -d 'Manage package owners'
346    complete -f -c npm -n "__fish_npm_using_command $c" -a pack -d 'Create a tarball from a package'
347    complete -f -c npm -n "__fish_npm_using_command $c" -a ping -d 'Ping npm registry'
348    complete -f -c npm -n "__fish_npm_using_command $c" -a pkg -d 'Manages your package.json'
349    complete -f -c npm -n "__fish_npm_using_command $c" -a prefix -d 'Display npm prefix'
350    complete -f -c npm -n "__fish_npm_using_command $c" -a publish -d 'Publish a package'
351    complete -f -c npm -n "__fish_npm_using_command $c" -a query -d 'Dependency selector query'
352    complete -f -c npm -n "__fish_npm_using_command $c" -a 'uninstall remove un' -d 'Remove a package'
353    complete -f -c npm -n "__fish_npm_using_command $c" -a repo -d 'Open package repository page in the browser'
354    complete -f -c npm -n "__fish_npm_using_command $c" -a restart -d 'Restart a package'
355    complete -f -c npm -n "__fish_npm_using_command $c" -a start -d 'Start a package'
356    complete -f -c npm -n "__fish_npm_using_command $c" -a stop -d 'Stop a package'
357    complete -f -c npm -n "__fish_npm_using_command $c" -a test -d 'Test a package'
358    complete -f -c npm -n "__fish_npm_using_command $c" -a root -d 'Display npm root'
359    complete -f -c npm -n "__fish_npm_using_command $c" -a 'search find' -d 'Search for packages'
360    complete -f -c npm -n "__fish_npm_using_command $c" -a star -d 'Mark your favorite packages'
361    complete -f -c npm -n "__fish_npm_using_command $c" -a stars -d 'View packages marked as favorites'
362    complete -f -c npm -n "__fish_npm_using_command $c" -a 'update up upgrade' -d 'Update package(s)'
363    complete -f -c npm -n "__fish_npm_using_command $c" -a unstar -d 'Remove star from a package'
364    complete -f -c npm -n "__fish_npm_using_command $c" -a version -d 'Bump a package version'
365    complete -f -c npm -n "__fish_npm_using_command $c" -a 'view info' -d 'View registry info'
366    complete -f -c npm -n "__fish_npm_using_command $c" -a whoami -d 'Display npm username'
367    complete -f -c npm -n "__fish_npm_using_command $c" -a 'link ln' -d 'Symlink a package folder'
368    complete -f -c npm -n "__fish_npm_using_command $c" -a profile -d 'Change settings on your registry profile'
369    complete -f -c npm -n "__fish_npm_using_command $c" -a prune -d 'Remove extraneous packages'
370    complete -f -c npm -n "__fish_npm_using_command $c" -a rebuild -d 'Rebuild a package'
371    complete -f -c npm -n "__fish_npm_using_command $c" -a team -d 'Manage organization teams and team memberships'
372    complete -f -c npm -n "__fish_npm_using_command $c" -a token -d 'Manage your authentication tokens'
373    complete -f -c npm -n "__fish_npm_using_command $c" -a unpublish -d 'Remove a package from the registry'
374    complete -f -c npm -n "__fish_npm_using_command $c" -a completion -d 'Tab Completion for npm'
375    complete -f -c npm -n "__fish_npm_using_command $c" -a shrinkwrap -d 'Lock down dependency versions'
376end
377
378# help-search
379complete -f -c npm -n __fish_npm_needs_command -a help-search -d 'Search npm help documentation'
380complete -f -c npm -n '__fish_npm_using_command help-search' -s l -l long -d 'Show extended information'
381complete -f -c npm -n '__fish_npm_using_command help-search' -s h -l help -d 'Display help'
382
383# hook
384set -l hook_commands 'add ls update rm'
385complete -f -c npm -n __fish_npm_needs_command -a hook -d 'Manage registry hooks'
386complete -f -c npm -n '__fish_npm_using_command hook' -n "not __fish_seen_subcommand_from $hook_commands" -a add -d 'Add a hook'
387complete -f -c npm -n '__fish_npm_using_command hook' -n "not __fish_seen_subcommand_from $hook_commands" -a ls -d 'List all active hooks'
388complete -f -c npm -n '__fish_npm_using_command hook' -n "not __fish_seen_subcommand_from $hook_commands" -a update -d 'Update an existing hook'
389complete -f -c npm -n '__fish_npm_using_command hook' -n "not __fish_seen_subcommand_from $hook_commands" -a rm -d 'Remove a hook'
390complete -f -c npm -n '__fish_npm_using_command hook' -n '__fish_seen_subcommand_from add' -l type -d 'Hook type'
391complete -x -c npm -n '__fish_npm_using_command hook' -l registry -d 'Registry base URL'
392complete -x -c npm -n '__fish_npm_using_command hook' -l otp -d '2FA one-time password'
393complete -f -c npm -n '__fish_npm_using_command hook' -s h -l help -d 'Display help'
394
395# init
396complete -c npm -n __fish_npm_needs_command -a 'init create' -d 'Create a package.json file'
397for c in init create innit
398    complete -f -c npm -n "__fish_npm_using_command $c" -s y -l yes -d 'Automatically answer "yes" to all prompts'
399    complete -f -c npm -n "__fish_npm_using_command $c" -s f -l force -d 'Removes various protections'
400    complete -x -c npm -n "__fish_npm_using_command $c" -l scope -d 'Create a scoped package'
401    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
402end
403
404# install
405# install-test
406# link
407complete -c npm -n __fish_npm_needs_command -a 'install add i' -d 'Install a package'
408complete -f -c npm -n __fish_npm_needs_command -a 'install-test it' -d 'Install package(s) and run tests'
409complete -f -c npm -n __fish_npm_needs_command -a 'link ln' -d 'Symlink a package folder'
410# typos are intentional
411for c in install add i in ins inst insta instal isnt isnta isntal isntall install-test it link ln
412    complete -f -c npm -n "__fish_npm_using_command $c" -s S -l save -d 'Save to dependencies'
413    complete -f -c npm -n "__fish_npm_using_command $c" -l no-save -d 'Prevents saving to dependencies'
414    complete -f -c npm -n "__fish_npm_using_command $c" -s P -l save-prod -d 'Save to dependencies'
415    complete -f -c npm -n "__fish_npm_using_command $c" -s D -l save-dev -d 'Save to devDependencies'
416    complete -f -c npm -n "__fish_npm_using_command $c" -s O -l save-optional -d 'Save to optionalDependencies'
417    complete -f -c npm -n "__fish_npm_using_command $c" -l save-peer -d 'Save to peerDependencies'
418    complete -f -c npm -n "__fish_npm_using_command $c" -s B -l save-bundle -d 'Also save to bundleDependencies'
419    complete -f -c npm -n "__fish_npm_using_command $c" -s E -l save-exact -d 'Save dependency with exact version'
420    complete -f -c npm -n "__fish_npm_using_command $c" -s g -l global -d 'Install package globally'
421    complete -x -c npm -n "__fish_npm_using_command $c" -l install-strategy -a 'hoisted nested shallow linked' -d 'Install strategy'
422    complete -x -c npm -n "__fish_npm_using_command $c" -l omit -a 'dev optional peer' -d 'Omit dependency type'
423    complete -x -c npm -n "__fish_npm_using_command $c" -l strict-peer-deps -d 'Treat conflicting peerDependencies as failure'
424    complete -x -c npm -n "__fish_npm_using_command $c" -l no-package-lock -d 'Ignore package-lock.json'
425    complete -f -c npm -n "__fish_npm_using_command $c" -l ignore-scripts -d "Don't run pre-, post- and life-cycle scripts"
426    complete -f -c npm -n "__fish_npm_using_command $c" -l no-audit -d "Don't submit audit reports"
427    complete -f -c npm -n "__fish_npm_using_command $c" -l no-bin-links -d "Don't symblink package executables"
428    complete -f -c npm -n "__fish_npm_using_command $c" -l no-fund -d "Don't display funding info"
429    complete -f -c npm -n "__fish_npm_using_command $c" -l dry-run -d 'Do not make any changes'
430    complete -f -c npm -n "__fish_npm_using_command $c" -l install-links -d 'Install file: protocol deps as regular deps'
431    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
432
433    if test $c != link -a $c != ln
434        complete -f -c npm -n "__fish_npm_using_command $c" -l foreground-scripts -d 'Run all build scripts in the foreground'
435        complete -f -c npm -n "__fish_npm_using_command $c" -l prefer-dedupe -d 'Prefer to deduplicate packages'
436    end
437end
438
439# logout
440complete -f -c npm -n __fish_npm_needs_command -a logout -d 'Log out of the registry'
441complete -x -c npm -n '__fish_npm_using_command logout' -l registry -d 'Registry base URL'
442complete -x -c npm -n '__fish_npm_using_command logout' -l scope -d 'Log out of private repository'
443complete -f -c npm -n '__fish_npm_using_command logout' -s h -l help -d 'Display help'
444
445# ls
446# ll, la
447complete -f -c npm -n __fish_npm_needs_command -a 'ls list ll' -d 'List installed packages'
448for c in ls list ll la
449    complete -f -c npm -n "__fish_npm_using_command $c" -s a -l all -d 'Also show indirect dependencies'
450    complete -f -c npm -n "__fish_npm_using_command $c" -l json -d 'Output JSON'
451    complete -f -c npm -n "__fish_npm_using_command $c" -s l -l long -d 'Show extended information'
452    complete -f -c npm -n "__fish_npm_using_command $c" -s p -l parseable -d 'Output parseable results'
453    complete -f -c npm -n "__fish_npm_using_command $c" -s g -l global -d 'List global packages'
454    complete -x -c npm -n "__fish_npm_using_command $c" -l depth -d 'Dependency recursion depth'
455    complete -x -c npm -n "__fish_npm_using_command $c" -l omit -a 'dev optional peer' -d 'Omit dependency type'
456    complete -f -c npm -n "__fish_npm_using_command $c" -l linked -d 'Only show linked packages'
457    complete -f -c npm -n "__fish_npm_using_command $c" -l package-lock-only -d 'Only use package-lock.json, ignore node_modules'
458    complete -f -c npm -n "__fish_npm_using_command $c" -l unicode -d 'Use unicode characters in the output'
459    complete -f -c npm -n "__fish_npm_using_command $c" -l no-unicode -d 'Use ascii characters over unicode glyphs'
460    complete -f -c npm -n "__fish_npm_using_command $c" -l install-links -d 'Install file: protocol deps as regular deps'
461    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
462end
463
464# outdated
465complete -f -c npm -n __fish_npm_needs_command -a outdated -d 'Check for outdated packages'
466complete -f -c npm -n '__fish_npm_using_command outdated' -s a -l all -d 'Also show indirect dependencies'
467complete -f -c npm -n '__fish_npm_using_command outdated' -l json -d 'Output JSON'
468complete -f -c npm -n '__fish_npm_using_command outdated' -s l -l long -d 'Show extended information'
469complete -f -c npm -n '__fish_npm_using_command outdated' -l parseable -d 'Output parseable results'
470complete -f -c npm -n '__fish_npm_using_command outdated' -s g -l global -d 'Check global packages'
471complete -f -c npm -n '__fish_npm_using_command outdated' -s h -l help -d 'Display help'
472
473# org
474complete -f -c npm -n __fish_npm_needs_command -a org -d 'Manage orgs'
475for c in org ogr
476    complete -f -c npm -n "__fish_npm_using_command $c" -n '__fish_is_nth_token 2' -a set -d 'Add a new user'
477    complete -f -c npm -n "__fish_npm_using_command $c" -n '__fish_is_nth_token 2' -a rm -d 'Remove a user'
478    complete -f -c npm -n "__fish_npm_using_command $c" -n '__fish_is_nth_token 2' -a ls -d 'List all users'
479
480    complete -f -c npm -n "__fish_npm_using_command $c" -n '__fish_is_nth_token 5' -n '__fish_seen_subcommand_from set' -a admin -d 'Add admin'
481    complete -f -c npm -n "__fish_npm_using_command $c" -n '__fish_is_nth_token 5' -n '__fish_seen_subcommand_from set' -a developer -d 'Add developer'
482    complete -f -c npm -n "__fish_npm_using_command $c" -n '__fish_is_nth_token 5' -n '__fish_seen_subcommand_from set' -a owner -d 'Add owner'
483    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
484end
485
486# owner
487for c in owner author
488    complete -f -c npm -n __fish_npm_needs_command -a "$c" -d 'Manage package owners'
489    complete -f -c npm -n "__fish_npm_using_command $c" -a ls -d 'List package owners'
490    complete -f -c npm -n "__fish_npm_using_command $c" -a add -d 'Add a new owner to package'
491    complete -f -c npm -n "__fish_npm_using_command $c" -a rm -d 'Remove an owner from package'
492    complete -x -c npm -n "__fish_npm_using_command $c" -l registry -d 'Registry base URL'
493    complete -x -c npm -n "__fish_npm_using_command $c" -l otp -d '2FA one-time password'
494    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
495end
496
497# pack
498complete -f -c npm -n __fish_npm_needs_command -a pack -d 'Create a tarball from a package'
499complete -f -c npm -n '__fish_npm_using_command pack' -l dry-run -d 'Do not make any changes'
500complete -f -c npm -n '__fish_npm_using_command pack' -l json -d 'Output JSON'
501complete -x -c npm -n '__fish_npm_using_command pack' -l pack-destination -a '(__fish_complete_directories)' -d 'Tarball destination directory'
502complete -f -c npm -n '__fish_npm_using_command pack' -s h -l help -d 'Display help'
503
504# ping
505complete -f -c npm -n __fish_npm_needs_command -a ping -d 'Ping npm registry'
506complete -x -c npm -n '__fish_npm_using_command ping' -l registry -d 'Registry base URL'
507complete -f -c npm -n '__fish_npm_using_command ping' -s h -l help -d 'Display help'
508
509# pkg
510complete -f -c npm -n __fish_npm_needs_command -a pkg -d 'Manages your package.json'
511complete -x -c npm -n '__fish_npm_using_command pkg' -a set -d 'Sets a value'
512complete -x -c npm -n '__fish_npm_using_command pkg' -a get -d 'Retrieves a value'
513complete -x -c npm -n '__fish_npm_using_command pkg' -a delete -d 'Deletes a key'
514complete -f -c npm -n '__fish_npm_using_command pkg' -s f -l force -d 'Removes various protections'
515complete -f -c npm -n '__fish_npm_using_command pkg' -l json -d 'Parse values with JSON.parse()'
516complete -f -c npm -n '__fish_npm_using_command pkg' -s h -l help -d 'Display help'
517
518# prefix
519complete -f -c npm -n __fish_npm_needs_command -a prefix -d 'Display npm prefix'
520complete -f -c npm -n '__fish_npm_using_command prefix' -s g -l global -d 'Display global prefix'
521complete -f -c npm -n '__fish_npm_using_command prefix' -s h -l help -d 'Display help'
522
523# profile
524set -l profile_commands 'enable-2fa disable-2fa get set'
525complete -f -c npm -n __fish_npm_needs_command -a profile -d 'Change settings on your registry profile'
526complete -x -c npm -n '__fish_npm_using_command profile' -n "not __fish_seen_subcommand_from $profile_commands" -a enable-2fa -d 'Enables two-factor authentication'
527complete -x -c npm -n '__fish_npm_using_command profile' -n "not __fish_seen_subcommand_from $profile_commands" -a disable-2fa -d 'Disables two-factor authentication'
528complete -x -c npm -n '__fish_npm_using_command profile' -n "not __fish_seen_subcommand_from $profile_commands" -a get -d 'Display profile properties'
529complete -x -c npm -n '__fish_npm_using_command profile' -n "not __fish_seen_subcommand_from $profile_commands" -a set -d 'Set the value of a profile property'
530complete -x -c npm -n '__fish_npm_using_command profile' -n '__fish_seen_subcommand_from enable-2fa' -a auth-only -d 'Require an OTP on profile changes'
531complete -x -c npm -n '__fish_npm_using_command profile' -n '__fish_seen_subcommand_from enable-2fa' -a auth-and-writes -d 'Also require an OTP on package changes'
532complete -f -c npm -n '__fish_npm_using_command profile' -s h -l help -d 'Display help'
533
534# prune
535complete -f -c npm -n __fish_npm_needs_command -a prune -d 'Remove extraneous packages'
536complete -x -c npm -n '__fish_npm_using_command prune' -l omit -a 'dev optional peer' -d 'Omit dependency type'
537complete -f -c npm -n '__fish_npm_using_command prune' -l dry-run -d 'Do not make any changes'
538complete -f -c npm -n '__fish_npm_using_command prune' -l json -d 'Output JSON'
539complete -f -c npm -n '__fish_npm_using_command prune' -l foreground-scripts -d 'Run all build scripts in the foreground'
540complete -f -c npm -n '__fish_npm_using_command prune' -l ignore-scripts -d "Don't run pre-, post- and life-cycle scripts"
541complete -f -c npm -n '__fish_npm_using_command prune' -l install-links -d 'Install file: protocol deps as regular deps'
542complete -f -c npm -n '__fish_npm_using_command prune' -s h -l help -d 'Display help'
543
544# publish
545complete -f -c npm -n __fish_npm_needs_command -a publish -d 'Publish a package'
546complete -x -c npm -n '__fish_npm_using_command publish' -l tag -d 'Upload to tag'
547complete -x -c npm -n '__fish_npm_using_command publish' -l access -d 'Restrict access' -a "public\t'Publicly viewable' restricted\t'Restricted access (scoped packages only)'"
548complete -f -c npm -n '__fish_npm_using_command publish' -l dry-run -d 'Do not make any changes'
549complete -x -c npm -n '__fish_npm_using_command publish' -l otp -d '2FA one-time password'
550complete -f -c npm -n '__fish_npm_using_command publish' -l provenance -d 'Link to build location when publishing from CI/CD'
551complete -f -c npm -n '__fish_npm_using_command publish' -s h -l help -d 'Display help'
552
553# query
554complete -f -c npm -n __fish_npm_needs_command -a query -d 'Dependency selector query'
555complete -f -c npm -n '__fish_npm_using_command query' -s g -l global -d 'Query global packages'
556complete -f -c npm -n '__fish_npm_using_command query' -s h -l help -d 'Display help'
557
558# rebuild
559complete -f -c npm -n __fish_npm_needs_command -a rebuild -d 'Rebuild a package'
560for c in rebuild rb
561    complete -x -c npm -n "__fish_npm_using_command $c" -s g -l global -d 'Rebuild global package'
562    complete -f -c npm -n "__fish_npm_using_command $c" -l foreground-scripts -d 'Run all build scripts in the foreground'
563    complete -f -c npm -n "__fish_npm_using_command $c" -l ignore-scripts -d "Don't run pre-, post- and life-cycle scripts"
564    complete -f -c npm -n "__fish_npm_using_command $c" -l no-bin-links -d "Don't symblink package executables"
565    complete -f -c npm -n "__fish_npm_using_command $c" -l install-links -d 'Install file: protocol deps as regular deps'
566    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
567end
568
569# repo
570complete -f -c npm -n __fish_npm_needs_command -a repo -d 'Open package repository page in the browser'
571complete -f -c npm -n '__fish_npm_using_command repo' -s g -l global -d 'Display global root'
572complete -x -c npm -n '__fish_npm_using_command repo' -l browser -d 'Set browser'
573complete -x -c npm -n '__fish_npm_using_command repo' -l no-browser -d 'Print to stdout'
574complete -x -c npm -n '__fish_npm_using_command repo' -l registry -d 'Registry base URL'
575complete -f -c npm -n '__fish_npm_using_command repo' -s h -l help -d 'Display help'
576
577# restart
578# start
579# stop
580# test
581complete -f -c npm -n __fish_npm_needs_command -a restart -d 'Restart a package'
582complete -f -c npm -n __fish_npm_needs_command -a start -d 'Start a package'
583complete -f -c npm -n __fish_npm_needs_command -a stop -d 'Stop a package'
584complete -f -c npm -n __fish_npm_needs_command -a test -d 'Test a package'
585for c in restart start stop test tst t
586    complete -f -c npm -n "__fish_npm_using_command $c" -s ignore-scripts -d "Don't run pre-, post- and life-cycle scripts"
587    complete -x -c npm -n "__fish_npm_using_command $c" -s script-shell -d 'The shell to use for scripts'
588    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
589end
590
591# root
592complete -f -c npm -n __fish_npm_needs_command -a root -d 'Display npm root'
593complete -f -c npm -n '__fish_npm_using_command root' -s g -l global -d 'Display global root'
594complete -f -c npm -n '__fish_npm_using_command root' -s h -l help -d 'Display help'
595
596# search
597complete -f -c npm -n __fish_npm_needs_command -a 'search find' -d 'Search for packages'
598for c in search find s se
599    complete -f -c npm -n "__fish_npm_using_command $c" -s l -l long -d 'Show extended information'
600    complete -f -c npm -n "__fish_npm_using_command $c" -l json -d 'Output JSON data'
601    complete -f -c npm -n "__fish_npm_using_command $c" -l color -a always -d 'Print color'
602    complete -x -c npm -n "__fish_npm_using_command $c" -l color -a always -d 'Print color'
603    complete -f -c npm -n "__fish_npm_using_command $c" -l no-color -d "Don't print color"
604    complete -f -c npm -n "__fish_npm_using_command $c" -s p -l parseable -d 'Output parseable results'
605    complete -f -c npm -n "__fish_npm_using_command $c" -l no-description -d "Don't show the description"
606    complete -x -c npm -n "__fish_npm_using_command $c" -l searchopts -d 'Space-separated search options'
607    complete -x -c npm -n "__fish_npm_using_command $c" -l searchexclude -d 'Space-separated options to exclude from search'
608    complete -x -c npm -n "__fish_npm_using_command $c" -l registry -d 'Registry base URL'
609    complete -f -c npm -n "__fish_npm_using_command $c" -l prefer-online -d 'Force staleness checks for cached data'
610    complete -f -c npm -n "__fish_npm_using_command $c" -l prefer-offline -d 'Bypass staleness checks for cached data'
611    complete -f -c npm -n "__fish_npm_using_command $c" -l offline -d 'Force offline mode'
612    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
613end
614
615# shrinkwrap
616complete -f -c npm -n __fish_npm_needs_command -a shrinkwrap -d 'Lock down dependency versions'
617complete -f -c npm -n '__fish_npm_using_command shrinkwrap' -s h -l help -d 'Display help'
618
619# star
620complete -f -c npm -n __fish_npm_needs_command -a star -d 'Mark your favorite packages'
621complete -x -c npm -n '__fish_npm_using_command star' -l registry -d 'Registry base URL'
622complete -f -c npm -n '__fish_npm_using_command star' -l unicode -d 'Use unicode characters in the output'
623complete -f -c npm -n '__fish_npm_using_command star' -l no-unicode -d 'Use ascii characters over unicode glyphs'
624complete -x -c npm -n '__fish_npm_using_command star' -l otp -d '2FA one-time password'
625complete -f -c npm -n '__fish_npm_using_command star' -s h -l help -d 'Display help'
626
627# stars
628complete -f -c npm -n __fish_npm_needs_command -a stars -d 'View packages marked as favorites'
629complete -x -c npm -n '__fish_npm_using_command stars' -l registry -d 'Registry base URL'
630complete -f -c npm -n '__fish_npm_using_command stars' -s h -l help -d 'Display help'
631
632# team
633set -l team_commands 'create destroy add rm ls'
634complete -f -c npm -n __fish_npm_needs_command -a team -d 'Manage organization teams and team memberships'
635complete -x -c npm -n '__fish_npm_using_command team' -n "not __fish_seen_subcommand_from $team_commands" -a create -d 'Create a new team'
636complete -x -c npm -n '__fish_npm_using_command team' -n "not __fish_seen_subcommand_from $team_commands" -a destroy -d 'Destroy an existing team'
637complete -x -c npm -n '__fish_npm_using_command team' -n "not __fish_seen_subcommand_from $team_commands" -a add -d 'Add a user to an existing team'
638complete -x -c npm -n '__fish_npm_using_command team' -n "not __fish_seen_subcommand_from $team_commands" -a rm -d 'Remove users from a team'
639complete -x -c npm -n '__fish_npm_using_command team' -n "not __fish_seen_subcommand_from $team_commands" -a ls -d 'List teams or team members'
640complete -x -c npm -n '__fish_npm_using_command team' -n 'not __fish_seen_subcommand_from ls' -l otp -d '2FA one-time password'
641complete -x -c npm -n '__fish_npm_using_command team' -l registry -d 'Registry base URL'
642complete -f -c npm -n '__fish_npm_using_command team' -s p -l parseable -d 'Output parseable results'
643complete -f -c npm -n '__fish_npm_using_command team' -l json -d 'Output JSON'
644complete -f -c npm -n '__fish_npm_using_command team' -s h -l help -d 'Display help'
645
646# token
647set -l token_commands 'create destroy add rm ls'
648complete -f -c npm -n __fish_npm_needs_command -a token -d 'Manage your authentication tokens'
649complete -x -c npm -n '__fish_npm_using_command token' -n "not __fish_seen_subcommand_from $token_commands" -a list -d 'Shows active authentication tokens'
650complete -x -c npm -n '__fish_npm_using_command token' -n "not __fish_seen_subcommand_from $token_commands" -a revoke -d 'Revokes an authentication token'
651complete -x -c npm -n '__fish_npm_using_command token' -n "not __fish_seen_subcommand_from $token_commands" -a create -d 'Create a new authentication token'
652complete -f -c npm -n '__fish_npm_using_command token' -n '__fish_seen_subcommand_from create' -l read-only -d 'Mark a token as unable to publish'
653complete -x -c npm -n '__fish_npm_using_command token' -n '__fish_seen_subcommand_from create' -l cidr -d 'List of CIDR address'
654complete -x -c npm -n '__fish_npm_using_command token' -l registry -d 'Registry base URL'
655complete -x -c npm -n '__fish_npm_using_command token' -l otp -d '2FA one-time password'
656complete -f -c npm -n '__fish_npm_using_command token' -s h -l help -d 'Display help'
657
658# update
659complete -f -c npm -n __fish_npm_needs_command -a 'update up upgrade' -d 'Update package(s)'
660for c in update up upgrade udpate
661    complete -f -c npm -n "__fish_npm_using_command $c" -s S -l save -d 'Save to dependencies'
662    complete -x -c npm -n "__fish_npm_using_command $c" -l no-save -d 'Do not remove package from your dependencies'
663    complete -f -c npm -n "__fish_npm_using_command $c" -s g -l global -d 'Update global package(s)'
664    complete -x -c npm -n "__fish_npm_using_command $c" -l install-strategy -a 'hoisted nested shallow linked' -d 'Install strategy'
665    complete -x -c npm -n "__fish_npm_using_command $c" -l omit -a 'dev optional peer' -d 'Omit dependency type'
666    complete -x -c npm -n "__fish_npm_using_command $c" -l strict-peer-deps -d 'Treat conflicting peerDependencies as failure'
667    complete -x -c npm -n "__fish_npm_using_command $c" -l no-package-lock -d 'Ignore package-lock.json'
668    complete -f -c npm -n "__fish_npm_using_command $c" -l foreground-scripts -d 'Run all build scripts in the foreground'
669    complete -f -c npm -n "__fish_npm_using_command $c" -l ignore-scripts -d "Don't run pre-, post- and life-cycle scripts"
670    complete -f -c npm -n "__fish_npm_using_command $c" -l no-audit -d "Don't submit audit reports"
671    complete -f -c npm -n "__fish_npm_using_command $c" -l no-bin-links -d "Don't symblink package executables"
672    complete -f -c npm -n "__fish_npm_using_command $c" -l no-fund -d "Don't display funding info"
673    complete -f -c npm -n "__fish_npm_using_command $c" -l dry-run -d 'Do not make any changes'
674    complete -f -c npm -n "__fish_npm_using_command $c" -l install-links -d 'Install file: protocol deps as regular deps'
675    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
676end
677
678# uninstall
679complete -f -c npm -n __fish_npm_needs_command -a 'uninstall remove un' -d 'Remove a package'
680for c in uninstall unlink remove rm r un
681    complete -x -c npm -n "__fish_npm_using_command $c" -d 'Remove package' -a '(__npm_installed_local_packages)'
682    complete -x -c npm -n "__fish_npm_using_command $c" -s g -l global -d 'Remove global package' -a '(__npm_installed_global_packages)'
683    complete -f -c npm -n "__fish_npm_using_command $c" -s S -l save -d 'Save to dependencies'
684    complete -x -c npm -n "__fish_npm_using_command $c" -l no-save -d 'Do not remove package from your dependencies'
685    complete -f -c npm -n "__fish_npm_using_command $c" -l install-links -d 'Install file: protocol deps as regular deps'
686end
687
688# unpublish
689complete -f -c npm -n __fish_npm_needs_command -a unpublish -d 'Remove a package from the registry'
690complete -x -c npm -n '__fish_npm_using_command unpublish' -l dry-run -d 'Do not make any changes'
691complete -x -c npm -n '__fish_npm_using_command unpublish' -s f -l force -d 'Removes various protections'
692complete -f -c npm -n '__fish_npm_using_command unpublish' -s h -l help -d 'Display help'
693
694# unstar
695complete -f -c npm -n __fish_npm_needs_command -a unstar -d 'Remove star from a package'
696complete -x -c npm -n '__fish_npm_using_command unstar' -l registry -d 'Registry base URL'
697complete -f -c npm -n '__fish_npm_using_command unstar' -l unicode -d 'Use unicode characters in the output'
698complete -f -c npm -n '__fish_npm_using_command unstar' -l no-unicode -d 'Use ascii characters over unicode glyphs'
699complete -x -c npm -n '__fish_npm_using_command unstar' -l otp -d '2FA one-time password'
700complete -f -c npm -n '__fish_npm_using_command unstar' -s h -l help -d 'Display help'
701
702# version
703complete -f -c npm -n __fish_npm_needs_command -a version -d 'Bump a package version'
704for c in version verison
705    complete -x -c npm -n "__fish_npm_using_command $c" -a 'major minor patch premajor preminor prepatch prerelease'
706    complete -f -c npm -n "__fish_npm_using_command $c" -l allow-same-version -d 'Allow same version'
707    complete -f -c npm -n "__fish_npm_using_command $c" -l no-commit-hooks -d "Don't run git commit hooks"
708    complete -f -c npm -n "__fish_npm_using_command $c" -l no-git-tag-version -d "Don't tag the commit"
709    complete -f -c npm -n "__fish_npm_using_command $c" -l json -d 'Output JSON'
710    complete -x -c npm -n "__fish_npm_using_command $c" -l preid -d 'The prerelease identifier'
711    complete -f -c npm -n "__fish_npm_using_command $c" -l sign-git-tag -d 'Sign the version tag'
712    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
713end
714
715# view
716complete -f -c npm -n __fish_npm_needs_command -a 'view info' -d 'View registry info'
717for c in view info v show
718    complete -f -c npm -n "__fish_npm_using_command $c" -n '__fish_is_nth_token 2'
719    complete -f -c npm -n "__fish_npm_using_command $c" -n '__fish_is_nth_token 3' -a 'author bin bugs description engines exports homepage keywords license main name repository scripts type types'
720    complete -f -c npm -n "__fish_npm_using_command $c" -n '__fish_is_nth_token 3' -a 'dependencies devDependencies optionalDependencies peerDependencies'
721    complete -f -c npm -n "__fish_npm_using_command $c" -n '__fish_is_nth_token 3' -a 'directories dist dist-tags gitHead maintainers readme time users version versions'
722    complete -f -c npm -n "__fish_npm_using_command $c" -l json -d 'Output JSON'
723    complete -f -c npm -n "__fish_npm_using_command $c" -s h -l help -d 'Display help'
724end
725
726# whoami
727complete -f -c npm -n __fish_npm_needs_command -a whoami -d 'Display npm username'
728complete -f -c npm -n '__fish_npm_using_command whoami' -a registry -d 'Check registry'
729complete -f -c npm -n '__fish_npm_using_command whoami' -s h -l help -d 'Display help'
730
731# misc
732complete -f -c npm -n '__fish_seen_subcommand_from add i in ins inst insta instal isnt isnta isntal isntall; and not __fish_is_switch' -a "(__npm_filtered_list_packages \"$npm_install\")"