From 266df07019afdd2a734de25b4f1fdbf9b58ed4bf Mon Sep 17 00:00:00 2001 From: Hoang Nguyen Date: Sat, 3 Feb 2024 00:00:00 +0700 Subject: [PATCH] feat(misc): add fish completion --- misc/fish/ghq.fish | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 misc/fish/ghq.fish diff --git a/misc/fish/ghq.fish b/misc/fish/ghq.fish new file mode 100644 index 0000000..0ce8548 --- /dev/null +++ b/misc/fish/ghq.fish @@ -0,0 +1,57 @@ +function __fish_ghq_complete_first_arg + set -l cmd (commandline -opc) + if test (count $cmd) -eq 1 + return 0 + end + return 1 +end + +# Remove any previous completion +complete -c ghq -e +# Don't suggest files +complete -c ghq -f + +# Global arguments +complete -c ghq -s 'h' -l 'help' -d 'Show help' +complete -c ghq -n '__fish_ghq_complete_first_arg' -s 'v' -l 'version' -d 'Print the version' + +# Global subcommands +complete -c ghq -n '__fish_ghq_complete_first_arg' -a 'get' -d 'Clone/sync with a remote repository' +complete -c ghq -n '__fish_ghq_complete_first_arg' -a 'list' -d 'List local repositories' +complete -c ghq -n '__fish_ghq_complete_first_arg' -a 'rm' -d 'Remove local repository' +complete -c ghq -n '__fish_ghq_complete_first_arg' -a 'root' -d 'Show repositories\' root' +complete -c ghq -n '__fish_ghq_complete_first_arg' -a 'create' -d 'Create a new repository' +complete -c ghq -n '__fish_ghq_complete_first_arg' -a 'h help' -d 'Shows a list of commands or help for one command' + +# Arguments for subcommands +complete -c ghq -n '__fish_seen_subcommand_from get' -s 'u' -l 'update' -d 'Update local repository if cloned already' +complete -c ghq -n '__fish_seen_subcommand_from get' -s 'p' -d 'Clone with SSH' +complete -c ghq -n '__fish_seen_subcommand_from get' -l 'shallow' -d 'Do a shallow clone' +complete -c ghq -n '__fish_seen_subcommand_from get' -s 'l' -l 'look' -d 'Look after get' +complete -c ghq -n '__fish_seen_subcommand_from get' -l 'vcs' -d 'Specify vcs backend for cloning' +complete -c ghq -n '__fish_seen_subcommand_from get' -s 's' -l 'silent' -d 'Clone or update silently' +complete -c ghq -n '__fish_seen_subcommand_from get' -l 'no-recursive' -d 'Prevent recursive fetching' +complete -c ghq -n '__fish_seen_subcommand_from get' -s 'b' -l 'branch' -d 'Specify branch name. This flag implies --single-branch on Git' +complete -c ghq -n '__fish_seen_subcommand_from get' -s 'P' -l 'parallel' -d 'Import parallelly' +complete -c ghq -n '__fish_seen_subcommand_from get' -l 'bare' -d 'Do a bare clone' + +complete -c ghq -n '__fish_seen_subcommand_from list' -s 'e' -l 'exact' -d 'Perform an exact match' +complete -c ghq -n '__fish_seen_subcommand_from list' -l 'vcs' -d 'Specify vcs backend for matching' +complete -c ghq -n '__fish_seen_subcommand_from list' -s 'p' -l 'full-path' -d 'Print full paths' +complete -c ghq -n '__fish_seen_subcommand_from list' -l 'unique' -d 'Print unique subpaths' + +complete -c ghq -n '__fish_seen_subcommand_from rm' -l 'dry-run' -d 'Do not remove actually' + +complete -c ghq -n '__fish_seen_subcommand_from root' -l 'all' -d 'Show all roots' + +complete -c ghq -n '__fish_seen_subcommand_from create' -l 'vcs' -d 'Specify vcs backend explicitly' + +# Complete VCS backend options for supported subcommands +complete -c ghq -n '__fish_seen_subcommand_from get list create' -n '__fish_seen_argument --vcs' -l 'vcs' -x -a 'git github codecommit' -d 'git' +complete -c ghq -n '__fish_seen_subcommand_from get list create' -n '__fish_seen_argument --vcs' -l 'vcs' -x -a 'svn subversion' -d 'subversion' +complete -c ghq -n '__fish_seen_subcommand_from get list create' -n '__fish_seen_argument --vcs' -l 'vcs' -x -a 'git-svn' -d 'git-svn' +complete -c ghq -n '__fish_seen_subcommand_from get list create' -n '__fish_seen_argument --vcs' -l 'vcs' -x -a 'hg mercurial' -d 'mercurial' +complete -c ghq -n '__fish_seen_subcommand_from get list create' -n '__fish_seen_argument --vcs' -l 'vcs' -x -a 'darcs' -d 'darcs' +complete -c ghq -n '__fish_seen_subcommand_from get list create' -n '__fish_seen_argument --vcs' -l 'vcs' -x -a 'pijul' -d 'pijul' +complete -c ghq -n '__fish_seen_subcommand_from get list create' -n '__fish_seen_argument --vcs' -l 'vcs' -x -a 'fossil' -d 'fossil' +complete -c ghq -n '__fish_seen_subcommand_from get list create' -n '__fish_seen_argument --vcs' -l 'vcs' -x -a 'bzr bazaar' -d 'bazaar'