fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
a35c3d4d1
master
1function __fish_clasp_list_projects 2clasp list --noShorten true2> /dev/null| 3string replace --regex'(.*) - https://script.google.com/d/(.*)/edit' '$2\\t$1' 4end 5 6function __fish_clasp_list_versions 7clasp versions2> /dev/null| 8string replace --regex'(\\d+) - (.*)' '$1\\t$2' | 9sed -n'2,$p' 10end 11 12function __fish_clasp_list_deployments 13clasp deployments2> /dev/null| 14string replace --regex --'- (\\S+) @(\\S+).*' '$1\\tversion $2' | 15sed -n'2,$p' 16end 17 18function __fish_clasp_list_advanced_services 19printf '%s\\t%s service\n' admin-sdk-directory'Admin SDK Directory' \ 20 admin-sdk-license-manager'Admin SDK Enterprise License Manager' \ 21 admin-sdk-groups-migration'Admin SDK Groups Migration' \ 22 admin-sdk-groups-settings'Admin SDK Groups Settings' \ 23 admin-sdk-reseller'Admin SDK Google Workspace Reseller' \ 24 admin-sdk-reports'Admin SDK Reports' \ 25 calendar'Advanced Calendar' \ 26 chat'Advanced Chat' \ 27 docs'Advanced Docs' \ 28 drive'Advanced Drive' \ 29 drive-activity'Google Drive Activity' \ 30 drive-labels'Advanced Drive Labels' \ 31 gmail'Advanced Gmail' \ 32 sheets'Advanced Sheets' \ 33 slides'Advanced Slides' \ 34 classroom Classroom\ 35 people'Advanced People' \ 36 contacts-people'Migrate from Contacts service to People API' \ 37 tasks Tasks 38end 39 40function __fish_clasp_list_functions 41find . -name'*.js' -exec sed -nE'/^\s*function/ s/^\s*function\s+(\w+).*$/\1/p' '{}' \; 42end 43 44function __fish_clasp_list_subcommands 45clasp --help| 46string match --regex'^ [a-z]' --entire| 47string replace --regex'^\\s{2}([a-z]+).*' '$1' 48end 49 50function __fish_clasp_seen_subcommands_from 51set -l cmd( commandline -poc) 52set -e cmd[ 1 ] 53 54test ( count $argv ) -gt ( count $cmd ) && return 1 55 56set -l i( count $argv ) 57set -l j( count $cmd ) 58while test $i -gt 0 59contains --$argv [ $i ] $cmd [ $j ] || return 1 60set i( math $i -1 ) 61set j( math $j -1 ) 62end 63 64return 0 65end 66 67# options 68complete -c clasp -s h -l help -d'Show [h]elp' 69complete -c clasp -s v -l version -d'Show [v]ersion' 70 71complete -c clasp -s A -l auth -d"Path to a '.clasprc.json' or to a directory with it" 72complete -c clasp -s I -l ignore -d"Path to a '.claspignore.json' or to a directory with it" 73complete -c clasp -s P -l project -d"Path to a '.clasp.json' or to a directory with it" 74complete -c clasp -s W -l why -d"Display some debugging info upon exit" 75 76# subcommands 77complete -c clasp -n __fish_use_subcommand -xa login -d"Log in to script.google.com" 78complete -c clasp -n __fish_use_subcommand -xa logout -d"Log out" 79complete -c clasp -n __fish_use_subcommand -xa create -d"Create a script" 80complete -c clasp -n __fish_use_subcommand -xa clone -d"Clone a project" 81complete -c clasp -n __fish_use_subcommand -xa pull -d"Fetch a remote project" 82complete -c clasp -n __fish_use_subcommand -xa push -d"Update the remote project" 83complete -c clasp -n __fish_use_subcommand -xa status -d"Lists files that will be pushed by 'push' subcommand" 84complete -c clasp -n __fish_use_subcommand -xa open -d"Open a script" 85complete -c clasp -n __fish_use_subcommand -xa deployments -d"List deployment IDs of a script" 86complete -c clasp -n __fish_use_subcommand -xa deploy -d"Deploy a project" 87complete -c clasp -n __fish_use_subcommand -xa undeploy -d"Undeploy a project" 88complete -c clasp -n __fish_use_subcommand -xa version -d"Create an immutable version of a script" 89complete -c clasp -n __fish_use_subcommand -xa versions -d"List versions of a script" 90complete -c clasp -n __fish_use_subcommand -xa list -d"List projects" 91complete -c clasp -n __fish_use_subcommand -xa logs -d"Show StackDriver logs" 92complete -c clasp -n __fish_use_subcommand -xa run -d"Run a function in your Apps Scripts project" 93complete -c clasp -n __fish_use_subcommand -xa apis -d"List, enable, or disable APIs" 94complete -c clasp -n __fish_use_subcommand -xa help -d"Show help for a command" 95 96# login options 97set login_condition'__fish_seen_subcommand_from login' 98complete -c clasp -n" $login_condition " -l no-localhost -d'Do not run a local server, manually enter code instead' 99complete -c clasp -n" $login_condition " -l creds -d'Specify a relative path to credentials' 100complete -c clasp -n" $login_condition " -l status -d'Show who is logged in' 101 102# create option 103set create_condition'__fish_seen_subcommand_from create' 104complete -c clasp -n" $create_condition " -l type -xa'standalone docs sheets slides forms webapp api' -d"A project type" 105complete -c clasp -n" $create_condition " -l title -d"A project title" 106complete -c clasp -n" $create_condition " -l parentId -d"A project container ID" 107complete -c clasp -n" $create_condition " -l rootDir -d"Path to a directory with project files" 108 109# clone options 110set clone_condition'__fish_seen_subcommand_from clone' 111complete -c clasp -n" $clone_condition " -l rootDir -d"Path to a directory project files" 112complete -c clasp -n" $clone_condition " -xa'(__fish_clasp_list_projects)' 113 114# pull options 115complete -c clasp -n'__fish_seen_subcommand_from pull' -l versionNumber -xa'(__fish_clasp_list_versions)' -d"A project version to pull" 116 117# push options 118set push_condition'__fish_seen_subcommand_from push' 119complete -c clasp -n" $push_condition " -s f -l force -d"Forcibly overwrite a remote manifest" 120complete -c clasp -n" $push_condition " -s w -l watch -d"Watch for local changes in non-ignored files and push when they occur" 121 122# status options 123complete -c clasp -n'__fish_seen_subcommand_from status' -l json -d"Show in JSON format" 124 125# open options 126set open_condition'__fish_seen_subcommand_from open' 127complete -c clasp -n" $open_condition " -l webapp -d"Open a web application in a browser" 128complete -c clasp -n" $open_condition " -l creds -d"Open the URL to create credentials" 129complete -c clasp -n" $open_condition " -l addon -d"List parent IDs and open the URL of the first one" 130complete -c clasp -n" $open_condition " -l deploymentId -d"Use a custom deployment ID with a web application" 131 132# deploy options 133set deploy_condition'__fish_seen_subcommand_from deploy' 134complete -c clasp -n" $deploy_condition " -s V -l versionNumber -d"A project version" 135complete -c clasp -n" $deploy_condition " -s d -l description -d"A deployment description" 136complete -c clasp -n" $deploy_condition " -s i -l deploymentId -xa'(__fish_clasp_list_deployments)' -d"A deployment ID to redeploy" 137 138# undeploy options 139set undeploy_condition'__fish_seen_subcommand_from undeploy' 140complete -c clasp -n" $undeploy_condition " -l all -d"Undeploy all deployments" 141complete -c clasp -n" $undeploy_condition " -xa'(__fish_clasp_list_deployments)' 142 143# list options 144complete -c clasp -n'__fish_seen_subcommand_from list' -l noShorten -d"Do not shorten long names" 145 146# logs options 147set logs_condition'__fish_seen_subcommand_from logs' 148complete -c clasp -n" $logs_condition " -l json -d"Show logs in JSON form" 149complete -c clasp -n" $logs_condition " -l open -d"Open the StackDriver logs in a browser" 150complete -c clasp -n" $logs_condition " -l setup -d"Setup StackDriver logs" 151complete -c clasp -n" $logs_condition " -l watch -d"Watch and list new logs" 152complete -c clasp -n" $logs_condition " -l simplified -d"Hide timestamps with logs" 153 154# run options 155set run_condition'__fish_seen_subcommand_from run' 156complete -c clasp -n" $run_condition " -l nondev -d"Run a function in non-development mode" 157complete -c clasp -n" $run_condition " -s p -l params -d"Specify parameters for a function as a JSON array" 158complete -c clasp -n" $run_condition " -xa'(__fish_clasp_list_functions)' 159 160# apis subcommands and options 161set apis_condition'__fish_seen_subcommand_from apis' 162set apis_subcommand_condition'__fish_clasp_seen_subcommands_from apis enable || __fish_clasp_seen_subcommands_from apis disable' 163complete -c clasp -n" $apis_condition " -xa list -d'List APIs' 164complete -c clasp -n" $apis_condition " -xa enable -d'Enable APIs' 165complete -c clasp -n" $apis_condition " -xa disable -d'Disable APIs' 166complete -c clasp -n" $apis_condition " -l open -d"Open API Console in a browser" 167complete -c clasp -n" $apis_subcommand_condition " -a'(__fish_clasp_list_advanced_services)' 168 169# help subcommands 170complete -c clasp -n'__fish_seen_subcommand_from help' -xa'(__fish_clasp_list_subcommands)'