fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
a9618477e
master
1# Returns exit code of 0 if apm hasn't received a command yet, e.g. `config` 2function __fish_apm_needs_command 3set -l cmd( commandline -xpc) 4if test ( count $cmd ) -eq 1 5return 0 6else if test ( count $cmd ) -gt 1 7for cin $cmd [ 2 .. -1 ] 8switch $c 9# Exclude options that are allowed to appear before command 10case --color --no-color help 11continue 12case '*' 13return 1 14end 15end 16return 0 17end 18return 1 19end 20 21# Returns exit code of 0 if any command (argv[1..-1]) appears once, ignores flags. 22function __fish_apm_using_command 23set -l commands$argv 24set -l cmd( commandline -xpc) 25if test ( count $cmd ) -gt 1 26set -l command_seen_once1 27for cin $cmd [ 2 .. -1 ] 28switch $c 29case '-*' 30continue 31case $commands 32# If the command is seen more than once then return 1 33if test $command_seen_once -eq 1 34set command_seen_once0 35else 36return 1 37end 38case '*' 39if test $command_seen_once -eq 0 40return 0 41else 42return 1 43end 44end 45end 46return $command_seen_once 47end 48return 1 49end 50 51# Check if `commandline` contains a set of subcommands 52function __fish_apm_includes_subcommand 53set -l cmd( commandline -xpc) 54for subcommandin $argv 55if contains $subcommand $cmd 56return 0 57end 58end 59return 1 60end 61 62# Lists all apm config items 63function __fish_apm_config_items 64apm config list| string match -r -v"^\s*;|^\s*\$" | string replace"\w*=\w*" \t 65end 66 67# Lists all installed atom packages 68function __fish_apm_list_packages 69apm list -b 70end 71 72if apm -h2>| string match -q"*Atom Package Manager*" 73# Completions for Atom Package Manager 74 75################## 76# global options # 77################## 78 79# help 80complete -f -c apm -n __fish_apm_needs_command -s h -l help -d"Display help" 81complete -f -c apm -n __fish_apm_needs_command -a help -d"Display help" 82complete -f -c apm -n'__fish_apm_using_command clean config dedupe deinstall delete dev develop docs erase featured home init install link linked links list ln lns login ls open outdated publish rebuild rebuild-module-cache remove rm search show star starred stars test uninstall unlink unpublish unstar update upgrade view' -s h -l help -d'Display help' 83 84# version 85complete -f -c apm -n __fish_apm_needs_command -s v -l version -d"Display version" 86 87# color 88complete -f -c apm -n __fish_apm_needs_command -l color -d"Enable colored output" 89complete -f -c apm -n __fish_apm_needs_command -l no-color -d"Disable colored output" 90 91############ 92# commands # 93############ 94 95# clean 96complete -f -c apm -n __fish_apm_needs_command -a clean -d"Deletes packages in node_modules not referenced 97as dependency in package.json" 98 99# config 100set -l config_subcommands"get set edit delete list" 101complete -f -c apm -n __fish_apm_needs_command -a config -d"Modify or list configuration items" 102complete -x -c apm -n"__fish_apm_using_command config; and not __fish_apm_includes_subcommand $config_subcommands " -a set -d'Set config item' 103complete -x -c apm -n"__fish_apm_using_command config; and not __fish_apm_includes_subcommand $config_subcommands " -a get -d'Get config item' 104complete -x -c apm -n"__fish_apm_using_command config; and not __fish_apm_includes_subcommand $config_subcommands " -a delete -d'Delete config item' 105complete -x -c apm -n"__fish_apm_using_command config; and not __fish_apm_includes_subcommand $config_subcommands " -a list -d'List config items' 106complete -x -c apm -n"__fish_apm_using_command config; and not __fish_apm_includes_subcommand $config_subcommands " -a edit -d'Edit config items' 107complete -x -c apm -n'__fish_apm_using_command config set get delete; and __fish_apm_includes_subcommand set get delete' -a'(__fish_apm_config_items)' 108 109# dedupe 110complete -f -c apm -n __fish_apm_needs_command -a dedupe -d"Reduce duplication in node_modules in current directory" 111 112# deinstall & delete & erase & remove & rm & uninstall 113set -l uninstall_commands"deinstall delete erase remove rm uninstall" 114complete -f -c apm -n __fish_apm_needs_command -a$uninstall_commands -d"Delete installed package(s) from ~/.atom/packages" 115complete -f -c apm -n"__fish_apm_using_command $uninstall_commands " -a'(__fish_apm_list_packages)' 116complete -f -c apm -n"__fish_apm_using_command $uninstall_commands " -l hard -d"Unlink package from ~/.atom/packages and ~/.atom/dev/packages" 117complete -f -c apm -n"__fish_apm_using_command $uninstall_commands " -s d -l dev -d"Unlink package from ~/.atom/dev/packages" 118 119# dev(elop) 120set -l dev_commands"dev develop" 121complete -f -c apm -n __fish_apm_needs_command -a$dev_commands -d"Clone install dependencies and link a package for development" 122complete -f -c apm -n"__fish_apm_using_command $dev_commands " -a'(__fish_apm_list_packages)' 123 124# docs & home & open 125set -l open_commands"docs home open" 126complete -f -c apm -n __fish_apm_needs_command -a$open_commands -d"Open a package's homepage in the default browser" 127complete -f -c apm -n"__fish_apm_using_command $open_commands " -s p -l print -d"Print URL instead of opening" 128complete -f -c apm -n"__fish_apm_using_command $open_commands " -a'(__fish_apm_list_packages)' 129 130# featured 131complete -f -c apm -n __fish_apm_needs_command -a featured -d"List Atom packages and themes currently featured in the 132atom.io registry" 133complete -f -c apm -n'__fish_apm_using_command featured' -l json -d"Output featured packages as JSON array" 134complete -f -c apm -n'__fish_apm_using_command featured' -s t -l themes -d"Only list themes" 135complete -x -c apm -n'__fish_apm_using_command featured' -s c -l compatible -d"Only list packages/themes compatible with specified Atom version" 136 137# init 138complete -f -c apm -n __fish_apm_needs_command -a init -d"Generates code scaffolding for theme or package" 139complete -r -c apm -n'__fish_apm_using_command init' -l template -d"Path to the package or theme template" 140complete -x -c apm -n'__fish_apm_using_command init' -s p -l package -d"Generates a basic package" 141complete -x -c apm -n'__fish_apm_using_command init' -s t -l theme -d"Generates a basic theme" 142complete -x -c apm -n'__fish_apm_using_command init' -s l -l language -d"Generates a basic language package" 143complete -r -c apm -n'__fish_apm_using_command init' -s c -l convert -d"Convert TextMate bundle/theme" 144 145# install 146complete -f -c apm -n __fish_apm_needs_command -a install -d"Install Atom package to ~/.atom/packages/<package_name>" 147complete -f -c apm -n'__fish_apm_using_command install' -l check -d"Check native build tools are installed" 148complete -f -c apm -n'__fish_apm_using_command install' -l verbose -d"Show verbose debug information" 149complete -r -c apm -n'__fish_apm_using_command install' -l packages-file -d"Specify text file containing packages to install" 150complete -f -c apm -n'__fish_apm_using_command install' -l production -d"Do not install dev dependencies" 151complete -x -c apm -n'__fish_apm_using_command install' -s c -l compatible -d"Only install packages/themes compatible with specified Atom version" 152complete -f -c apm -n'__fish_apm_using_command install' -s s -l silent -d"Set npm log level to silent" 153complete -f -c apm -n'__fish_apm_using_command install' -s q -l quiet -d"Set npm log level to quiet" 154 155# link & ln 156set -l link_commands"link ln" 157complete -f -c apm -n __fish_apm_needs_command -a$link_commands -d"Create a symlink for the package in ~/.atom/packages" 158complete -f -c apm -n"__fish_apm_using_command $link_commands " -s d -l dev -d"Link to ~/.atom/dev/packages" 159 160# linked & links & lns 161set -l linked_commands"linked links lns" 162complete -f -c apm -n __fish_apm_needs_command -a$linked_commands -d"List all symlinked packages in ~/.atom/packages and 163~/.atom/dev/packages" 164 165# list & ls 166set -l list_commands"list ls" 167complete -f -c apm -n __fish_apm_needs_command -a$list_commands -d"List all installed and bundled packages" 168complete -f -c apm -n"__fish_apm_using_command $list_commands " -s b -l bare -d"Print packages one per line with no formatting" 169complete -f -c apm -n"__fish_apm_using_command $list_commands " -s d -l dev -d"Include dev packages" 170complete -f -c apm -n"__fish_apm_using_command $list_commands " -s i -l installed -d"Only list installed packages/themes" 171complete -f -c apm -n"__fish_apm_using_command $list_commands " -s j -l json -d"Output all packages as a JSON object" 172complete -f -c apm -n"__fish_apm_using_command $list_commands " -s l -l links -d"Include linked packages" 173complete -f -c apm -n"__fish_apm_using_command $list_commands " -s t -l themes -d"Only list themes" 174complete -f -c apm -n"__fish_apm_using_command $list_commands " -s p -l packages -d"Only list packages" 175 176# login 177complete -f -c apm -n __fish_apm_needs_command -a login -d"Save Atom API token to keychain" 178complete -x -c apm -n"__fish_apm_using_command login" -l token -d"Specify API token" 179 180# outdated & upgrade & update 181set -l upgrade_commands"outdated upgrade update" 182complete -f -c apm -n __fish_apm_needs_command -a$upgrade_commands -d"Upgrade out of date packages" 183complete -f -c apm -n"__fish_apm_using_command $upgrade_commands " -l json -d"Output outdated packages as JSON array" 184complete -x -c apm -n"__fish_apm_using_command $upgrade_commands " -l compatible -d"Only install packages/themes compatible with specified Atom version" 185complete -f -c apm -n"__fish_apm_using_command $upgrade_commands " -l verbose -d"Show verbose debug information" 186complete -f -c apm -n"__fish_apm_using_command $upgrade_commands " -s c -l confirm -d"Confirm before installing updates" 187complete -f -c apm -n"__fish_apm_using_command $upgrade_commands " -s l -l list -d"List but don't install the outdated packages" 188 189# publish 190set -l publish_subcommands"major minor patch build" 191complete -f -c apm -n __fish_apm_needs_command -a publish -d"Publish new version of package in current working directory" 192complete -f -c apm -n"__fish_apm_using_command publish; and not __fish_apm_includes_subcommand $publish_subcommands " -a$publish_subcommands -d"Semantic version category for new version" 193complete -x -c apm -n'__fish_apm_using_command publish' -s t -l tag -d"Specify a tag to publish" 194complete -x -c apm -n'__fish_apm_using_command publish' -s r -l rename -d"Specify a new name for the package" 195 196# rebuild 197complete -f -c apm -n __fish_apm_needs_command -a rebuild -d"Rebuild modules installed in node_modules in current working directory" 198 199# rebuild-module-cache 200complete -f -c apm -n __fish_apm_needs_command -a rebuild-module-cache -d"Rebuild module cache for installed packages" 201 202# search 203complete -f -c apm -n __fish_apm_needs_command -a search -d"Search for Atom packages/themes in the atom.io registry" 204complete -f -c apm -n'__fish_apm_using_command search' -l json -d"Output matching packages as JSON array" 205complete -f -c apm -n'__fish_apm_using_command search' -s p -l packages -d"Search only non-theme packages" 206complete -f -c apm -n'__fish_apm_using_command search' -s t -l themes -d"Search only themes" 207 208# show & view 209set -l show_commands"show view" 210complete -f -c apm -n __fish_apm_needs_command -a$show_commands -d"View information about package/theme in the atom.io registry" 211complete -f -c apm -n"__fish_apm_using_command $show_commands " -l json -d"Output as JSON array" 212complete -x -c apm -n"__fish_apm_using_command $show_commands " -l compatible -d"Show latest version compatible with specified Atom version" 213 214# star 215complete -f -c apm -n __fish_apm_needs_command -a star -d"Star the given packages on https://atom.io" 216complete -f -c apm -n'__fish_apm_using_command star' -l installed -d"Star all packages in ~/.atom/packages" 217 218# starred & stars 219set -l stars_commands"starred stars" 220complete -f -c apm -n __fish_apm_needs_command -a$stars_commands -d"List or install starred Atom packages and themes" 221complete -f -c apm -n"__fish_apm_using_command $stars_commands " -l json -d"Output packages as JSON array" 222complete -f -c apm -n"__fish_apm_using_command $stars_commands " -s i -l install -d"Install the starred packages" 223complete -f -c apm -n"__fish_apm_using_command $stars_commands " -s t -l themes -d"Only list themes" 224complete -x -c apm -n"__fish_apm_using_command $stars_commands " -s u -l user -d"GitHub username to show starred packages for" 225 226# test 227complete -f -c apm -n __fish_apm_needs_command -a test -d"Runs the package's tests contained within the spec directory" 228complete -r -c apm -n'__fish_apm_using_command test' -s p -l path -d"Path to atom command" 229 230# unlink 231complete -f -c apm -n __fish_apm_needs_command -a unlink -d"Delete the symlink in ~/.atom/packages for the package" 232complete -f -c apm -n'__fish_apm_using_command unlink' -l hard -d"Unlink package from ~/.atom/packages and ~/.atom/dev/packages" 233complete -f -c apm -n'__fish_apm_using_command unlink' -s d -l dev -d"Unlink package from ~/.atom/dev/packages" 234complete -f -c apm -n'__fish_apm_using_command unlink' -s a -l all -d"Unlink all packages in ~/.atom/packages and ~/.atom/dev/packages" 235 236# unpublish 237complete -f -c apm -n __fish_apm_needs_command -a unpublish -d"Remove published package or version from the atom.io registry" 238complete -f -c apm -n'__fish_apm_using_command unpublish' -s f -l force -d"Do not prompt for confirmation" 239 240# unstar 241complete -f -c apm -n __fish_apm_needs_command -a unstar -d"Unstar given packages on https://atom.io" 242 243else 244# Completions for the Advanced Power Management client 245 246complete -f -c apm -s V -l version -d"Display version and exit" 247complete -f -c apm -s v -l verbose -d"Print APM info" 248complete -f -c apm -s m -l minutes -d"Print time remaining" 249complete -f -c apm -s M -l monitor -d"Monitor status info" 250complete -f -c apm -s S -l standby -d"Request APM standby mode" 251complete -f -c apm -s s -l suspend -d"Request APM suspend mode" 252complete -f -c apm -s d -l debug -d"APM status debugging info" 253end