summary refs log tree commit diff
path: root/Completion/Unix/Command/_myrepos
blob: d26c1245b2e6e6572fdc1f7756a1d9606f769ba8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#compdef mr

#
# A zsh completion script for myrepos (http://myrepos.branchable.com/)
#

# This script does not handle user defined alias nor user defined actions (lib,
# plugins)


local curcontext="$curcontext" state state_descr line ret=1
local -a arguments
typeset -A opt_args
typeset -g mr_subcommands mr_alias

arguments=(
  '(-d --directory)'{-d,--directory}'[specify the topmost directory that mr should work in]:directory:_files -/'
  '(-c --config)'{-c,--config}'[use the specified mrconfig file]:mrconfig:_files'
  '(-f --force)'{-f,--force}'[force mr to act on repositories that would normally be skipped]'
  '--force-env[force mr to execute even though potentially dangerous env variables]'
  '(-v --verbose)'{-v,--verbose}'[be verbose]'
  '(-m --minimal)'{-m,--minimal}'[minimise output]'
  '(-q --quiet)'{-q,--quiet}"[suppress mr's usual output]"
  '(-k --insecure)'{-k,--insecure}'[accept untrusted SSL certificates when bootstrapping]'
  '(-s --stats)'{-s,--stats}'[expand the statistics line displayed at the end]'
  '(-i --interactive)'{-i,--interactive}'[start a subshell if a repository fails to be processed]'
  '(-n --no-recurse)'{-n,--no-recurse}'[specify the recursivity depth into repositories]::number'
  '(-j --jobs)'{-j,--jobs}'[number of jobs run in parallel]::number'
  '--cache[save the command result to ~/.mrcache/]'
  '--cached[process cached commands]'
  '--uncache[remove the cached output]'
  '--top[cd to the top of the repo before running any commands]'
  '(-t --trust-all)'{-t,--trust-all}'[trust all mrconfig files]'
  \!{-p,--path} # this obsolete flag is ignored
  ':mr commands:->subcommand'
  '*::: := ->option-or-argument'
)

_arguments -C $arguments && ret=0

case $state in
  (subcommand)

    mr_subcommands=(
      "checkout:check out any repositories that are not already checked out"
      "update:update each repository"
      "status:display a status report for each repository"
      "clean:print/remove ignored or untracked files and other cruft"
      "commit:commit changes to each repository"
      "record:record changes to the local repository"
      "fetch:fetch from each repository's remote repository"
      "push:push committed local changes to remote repository"
      "diff:show a diff of uncommitted changes"
      "log:show the commit log"
      "grep:search for a pattern in each repository"
      "run:run the specified command in each repository"
      "bootstrap:use a 'source' as .mrconfig file"
      "list:list the repositories that mr will act on"
      "register:register an existing repository in a mrconfig file"
      "config:get and set value from a mrconfig file"
      "offline:advise mr that it is in offline mode"
      "online:advise mr that it is in online mode"
      "remember:remember a command to be run later"
      "help:display this help."
    )

    mr_alias=(
      "co:check out any repositories that are not already checked out"
      "ci:commit changes to each repository"
      "ls:list the repositories that mr will act on"
    )

    _describe -t commands 'command' mr_subcommands -- mr_alias && ret=0

  ;;
  (option-or-argument)
    curcontext=${curcontext%:*}-$line[1]:
    case $line[1] in
      (clean)
        _arguments \
          '-f[allow removing the files]' \
          '*: :' && ret=0
      ;;
      (commit|ci|record)
        _arguments \
          '-m[allow specifying a commit message]' \
          '*: :' && ret=0
      ;;
      (grep)
        _message 'search pattern'
      ;;
      (run)
        _message 'command to run'
      ;;
      (bootstrap)
        if [[ $CURRENT -eq 2 ]]; then
          _alternative \
            'urls:URL:_urls' \
            'local:local file or stdin:_files'
        elif [[ $CURRENT -eq 3 ]]; then
          _directories
        fi
      ;;
      (register)
        _directories
      ;;
      (config)
        case $CURRENT in
          (2) _message -e section 'section name';&
          (3) _message -e setting '"setting" or "setting=value"';&
        esac
      ;;
      (remember)
        _describe -t commands 'command' mr_subcommands -- mr_alias && ret=0
      ;;
      (checkout|co|update|status|fetch|push|diff|log|list|ls|offline|online|help)
        _message 'no arguments'
      ;;
      (*)
        _default && ret=0
      ;;
    esac
  ;;
esac

return ret