diff --git a/resources/shell/bash/ghr-completion.bash b/resources/shell/bash/ghr-completion.bash index 2fd0ee3..142d7d6 100644 --- a/resources/shell/bash/ghr-completion.bash +++ b/resources/shell/bash/ghr-completion.bash @@ -43,11 +43,17 @@ __ghr_complete() { cword="${COMP_WORDS[COMP_CWORD]}" if [ "${COMP_CWORD}" = 1 ]; then - COMPREPLY=($(__ghr_complete__static "${cword}" --help cd clone delete help init open browse path profile shell version)) + COMPREPLY=($(__ghr_complete__static "${cword}" --help add browse cd clone delete help init list open path profile shell sync version)) return 0 fi case "${COMP_WORDS[1]}" in + add) + COMPREPLY=($(__ghr_complete__static "${cword}" --help)) + ;; + browse) + COMPREPLY=($(__ghr_complete__repos "${cword}")) + ;; cd) COMPREPLY=($(__ghr_complete__repos "${cword}")) ;; @@ -60,6 +66,9 @@ __ghr_complete() { init) COMPREPLY=($(__ghr_complete__static "${cword}" --help)) ;; + list) + COMPREPLY=($(__ghr_complete__static "${cword}" --help --no-host --no-owner -p --path)) + ;; open) if [ "${COMP_CWORD}" = 2 ]; then COMPREPLY=($(__ghr_complete__repos "${cword}" --help)) @@ -68,9 +77,6 @@ __ghr_complete() { COMPREPLY=($(compgen -c -- "${cword}")) fi ;; - browse) - COMPREPLY=($(__ghr_complete__repos "${cword}")) - ;; path) COMPREPLY=($(__ghr_complete__repos "${cword}")) ;; @@ -90,6 +96,9 @@ __ghr_complete() { shell) COMPREPLY=($(__ghr_complete__static "${cword}" --help)) ;; + sync) + COMPREPLY=($(__ghr_complete__static "${cword}" --help dump restore)) + ;; version) COMPREPLY=($(__ghr_complete__static "${cword}" --help)) ;; diff --git a/resources/shell/fish/ghr-completion.fish b/resources/shell/fish/ghr-completion.fish index a5a4eca..12cbe8b 100644 --- a/resources/shell/fish/ghr-completion.fish +++ b/resources/shell/fish/ghr-completion.fish @@ -6,20 +6,25 @@ end complete -c ghr -f # Complete commands with their description +complete -c ghr -n "__fish_is_arg_n 1" -a add -d "Add an existing repository into the ghr managed directory" +complete -c ghr -n "__fish_is_arg_n 1" -a browse -d "Browse a repository on web" complete -c ghr -n "__fish_is_arg_n 1" -a cd -d "Change directory to one of the managed repositories (Shell extension required)" complete -c ghr -n "__fish_is_arg_n 1" -a clone -d "Clones a Git repository to local" complete -c ghr -n "__fish_is_arg_n 1" -a delete -d "Deletes a repository from local" complete -c ghr -n "__fish_is_arg_n 1" -a init -d "Initialises a Git repository in local" complete -c ghr -n "__fish_is_arg_n 1" -a list -d "Lists all managed repositories" complete -c ghr -n "__fish_is_arg_n 1" -a open -d "Opens a repository in an application" -complete -c ghr -n "__fish_is_arg_n 1" -a browse -d "Browse a repository on web" complete -c ghr -n "__fish_is_arg_n 1" -a path -d "Prints the path to root, owner, or a repository" complete -c ghr -n "__fish_is_arg_n 1" -a profile -d "Manages profiles to use in repositories" complete -c ghr -n "__fish_is_arg_n 1" -a shell -d "Writes a shell script to extend ghr features" +complete -c ghr -n "__fish_is_arg_n 1" -a sync -d "Sync repositories between your devices" complete -c ghr -n "__fish_is_arg_n 1" -a version -d "Prints the version of this application" +# Complete the 2nd argument of add command using the file path +complete -c ghr -n "__fish_is_arg_n 2; and __fish_seen_subcommand_from add" -f + # Complete the 2nd argument of cd, delete, path, open, and browse commands using the repository list -complete -c ghr -n "__fish_is_arg_n 2; and __fish_seen_subcommand_from cd delete path open browse" -a "(ghr list)" +complete -c ghr -n "__fish_is_arg_n 2; and __fish_seen_subcommand_from browse cd delete path open" -a "(ghr list)" # Complete the 3rd argument of open command using the known command list complete -c ghr -n "__fish_is_arg_n 3; and __fish_seen_subcommand_from open" -a "(complete -C '')" @@ -31,3 +36,7 @@ complete -c ghr -n "__fish_is_arg_n 2; and __fish_seen_subcommand_from profile" # Complete the 3rd argument of profile list subcommand using the profile list complete -c ghr -n "__fish_is_arg_n 3; and __fish_seen_subcommand_from profile; and __fish_seen_subcommand_from show apply" -a "(ghr profile list --short)" + +# Complete subcommands of sync command with their description +complete -c ghr -n "__fish_is_arg_n 2; and __fish_seen_subcommand_from sync" -a dump -d "Dump remotes and the current ref of all repositories" +complete -c ghr -n "__fish_is_arg_n 2; and __fish_seen_subcommand_from sync" -a restore -d "Restore repositories from the dumped file"