aboutsummaryrefslogtreecommitdiffstats
path: root/src/_tox
blob: 1ccc1690f99ae6f47b2ecfa171d13a490615b0be (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#compdef tox
# ------------------------------------------------------------------------------
# Description
# -----------
#
#  Completion script for tox 4.32.0 (https://tox.readthedocs.io).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
#  * Julien Nicoulaud <julien.nicoulaud@gmail.com>
#
# ------------------------------------------------------------------------------

_tox() {
  typeset -A opt_args
  local context state line
  local curcontext="$curcontext"
  local ret=1

  local -a stderr_colors=(
    BLACK BLUE CYAN GREEN LIGHTBLACK_EX LIGHTBLUE_EX LIGHTCYAN_EX LIGHTGREEN_EX LIGHTMAGENTA_EX
    LIGHTRED_EX LIGHTWHITE_EX LIGHTYELLOW_EX MAGENTA RED RESET WHITE YELLOW
  )

  local -a options=(
    '(- 1 *)'{-h,--help}'[show help options]'
    '--colored[should output be enriched with colors]: :(yes no)'
    '--stderr-color[color for stderr output]:color:(($stderr_colors))'
    '--exit-and-dump-after[dump tox threads after specified seconds and exit the app]:seconds'
    '(-c --conf)'{-c,--conf}'[configuration file/folder for tox]:file_or_dir:_files'
    '--workdir[tox working directory]:dir:_files -/'
    '--root[project root directory]:dir:_files -/'
    '--runner[the tox run engine to use]:runner:(virtualenv)'
    '--no-provision[do not perform provision]:json:_files -g "*.json"'
    '--no-recreate-provision[do not recreate provision tox environment]'
    '(-r --recreate)'{-r,--recreate}'[recreate the tox environments]'
    '--matrix-scope[emit a github matrix specifix to scope mentioned]:scope:(all galaxy sanity integration unit)'
    '--gh-matrix[emit a github matrix]'
    '--ansible[enable ansible testing]'
  )

  _arguments -C \
    '(- 1 *)'{-h,--help}'[show help options]' \
    '--colored[should output be enriched with colors]: :(yes no)' \
    '--stderr-color[color for stderr output]:color:(($stderr_colors))' \
    '--exit-and-dump-after[dump tox threads after specified seconds and exit the app]:seconds' \
    '(-c --conf)'{-c,--conf}'[configuration file/folder for tox]:file_or_dir:_files' \
    '--workdir[tox working directory]:dir:_files -/' \
    '--root[project root directory]:dir:_files -/' \
    '--runner[the tox run engine to use]:runner:(virtualenv)' \
    '(- *)--version[show program and plugins version and exit]' \
    '--no-provision[do not perform provision]:json:_files -g "*.json"' \
    '--no-recreate-provision[do not recreate provision tox environment]' \
    '(-r --recreate)'{-r,--recreate}'[recreate the tox environments]' \
    '--matrix-scope[emit a github matrix specifix to scope mentioned]:scope:(all galaxy sanity integration unit)' \
    '--gh-matrix[emit a github matrix]' \
    '--ansible[enable ansible testing]' \
    \*{-x,--override}'[configuration override(s)]:override' \
    \*{-v,--verbose}'[increase verbosity]' \
    \*{-q,--quiet}'[decrease verbosity]' \
    '1: :_tox_commands' \
    '*::arg:->args' \
    && ret=0

  case "$state" in
    (args)
      case $words[1] in
        (run|run-parallel|depends|exec|list|quickstart|schema|config|devenv)
          options+=(
            '--result-json[write a JSON file with detailed information]:file:_files'
            '--hashseed[set PYTHONHASHSEED to the specified seed before running commands]:sed'
            '--discover[for Python discovery first try these Python executables]:file:_files'
            '(--list-dependencies --no-list-dependencies)--list-dependencies[list the dependencies installed during environment setup]'
            '(--list-dependencies --no-list-dependencies)--no-list-dependencies[never list the dependencies]'
            '--develop[install package in development mode]'
          )
          ;|
        (run|run-parallel|direnv)
          options+=(
            '-m[label to evaluate]:label'
            '-f[factor to evaluate]:factor'
          )
          ;|
        (run|run-parallel|exec|devenv)
          options+=(
            '(-s --skip-missing-interpreters)'{-s,--skip-missing-interpreters}'[do not fail tests for missing interpreters]'
            '(-n --notest)'{-n,--notest}'[do not run the test commands]'
            '(-b --pkg-only --sdistonly)'{-b,--pkg-only,--sdistonly}'[only perform the packaging activity]'
            '--installpkg[use specified package for installation into venv]:package'
            '--develop[install package in development mode]'
            '--no-recreate-pkg[do not recreate packaging tox environment(s)]'
            '--skip-pkg-install[skip package installation for this run]'
            '-e[enumerate all environments]:env'
            '--skip-env[exclude all environments selected that match this regular expression]:pattern'
          )
          ;|
        (run-parallel|legacy)
          options+=(
            '(-p --parallel)'{-p,--parallel}'[run tox environments in parallel]:num'
            '(-o --parallel-live)'{-o,--parallel-live}'[connect to stdout while running environments]'
            '--parallel-no-spinner[run tox environments in parallel but do not show the spinner]'
          )
          ;;
        (config)
          options+=(
            '-k[list just configuration keys specified]'
            '--core[show core options]'
          )
          ;;
        (schema)
          options+=(
            '--strict[disallow extra properties in configuration]'
          )
          ;;
        (legacy)
          options+=(
            '--force-dep[force a certain version of one of the dependencies]:req'
          )
          ;;
      esac

      _arguments $options[@] && ret=0
      ;;
  esac

  return ret
}

(( $+functions[_tox_commands] )) ||
_tox_commands() {
  local -a commands=(
    'run:run environments'
    'run-parallel:run environments in parallel'
    'depends:visualize tox environment dependencies'
    'list:list environment'
    'devenv:set up a development environment at ENVDIR'
    'schema:ganerate schema for tox configuration'
    'config:show tox configuration'
    'quickstart:quickly create a tox config file for a Python project'
    'exec:execute an arbitrary command within a tox environment'
    'legacy:legacy entry-point command'
  )
  _describe -t commands 'command' commands "$@"
}

(( $+functions[_tox_envs_list] )) ||
_tox_envs_list() {
  local envs; envs=($(_call_program envs $service --listenvs-all))
  if [ ${#envs} -gt 0 ]; then
    _values -s , 'tox environments' "${envs[@]}"
  else
    _message 'tox environments (none found)'
  fi
}

_tox "$@"

# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et