forked from nix-community/nix-zsh-completions
-
Notifications
You must be signed in to change notification settings - Fork 1
/
_nixops
204 lines (196 loc) · 6.69 KB
/
_nixops
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#compdef nixops
#autoload
_nix-common-options
# List of valid commands
local -a _1st_arguments
_1st_arguments=(
"list:list all known deployments"\
"create:create a new deployment"\
"modify:modify an existing deployment"\
"clone:clone an existing deployment"\
"delete:delete a deployment"\
"info:show the state of the deployment"\
"check:check the state of the machines in the network"\
"set-args:persistently set arguments to the deployment specification"\
"deploy:deploy the network configuration"\
"send-keys:send encryption keys"\
"destroy:destroy all resources in the specified deployment"\
"stop:stop all virtual machines in the network"\
"start:start all virtual machines in the network"\
"reboot:reboot all virtual machines in the network"\
"show-physical:print the physical network expression"\
"ssh:login on the specified machine via SSH"\
"ssh-for-each:execute a command on each machine via SSH"\
"scp:copy files to or from the specified machine via scp"\
"rename:rename machine in network"\
"backup:make snapshots of persistent disks in network (EC2-only)"\
"backup-status:get status of backups"\
"remove-backup:remove a given backup"\
"clean-backups:remove old backups"\
"restore:restore machines based on snapshots of persistent disks in network (EC2-only)"\
"show-option:print the value of a configuration option"\
"list-generations:list previous configurations to which you can roll back"\
"rollback:roll back to a previous configuration"\
"delete-generation:remove a previous configuration"\
"show-console-output:print the machines console output on stdout"\
"dump-nix-paths:dump Nix paths referenced in deployments"\
"export:export the state of a deployment"\
"import:import deployments into the state file"\
"edit:open the deployment specification in \$EDITOR"\
)
# Options valid for every command
local -a _nixops_common_arguments
_nixops_common_arguments=(
'(--state -s)'{--state,-s}'[Path to state file that contains the deployments]:Statefile:_files -g \*.nixops'\
'(--deployment -d)'{--deployment,-d}'[UUID or symbolic name of deployment on which to operate]'\
'--confirm[Automatically confirm "dangerous" actions]'\
'--debug[Turn on debugging output]'\
)
local -a _nixops_include_exclude
_nixops_include_exclude=(
'--include[Only operate on the specified machines]:Machine Names:_hosts' \
'--exclude[Do not operate on the specified machines]:Machine Names:_hosts' \
)
local -a _nixops_search_path_args
_nixops_search_path_args=(
'-I[Add path to the Nix expression search path for all future evaluations]:Path:_nix_complete_includes' \
)
_arguments \
$_nix_boilerplate_opts \
'*:: :->subcmds' && return 0
if (( CURRENT==1 )); then
_describe -t commands "nixos-container subcommands" _1st_arguments
return
fi
case "$words[1]" in
create)
_arguments \
$_nixops_common_arguments\
$_nixops_search_path_args \
'*:Nix Expressions:_nix_complete_dotnix_files'
;;
modify)
_arguments \
$_nixops_common_arguments\
$_nixops_search_path_args \
'(--name -n)'{--name,-n}'[Change the symbolic name]:New Name:( )'\
;;
clone)
_arguments \
$_nixops_common_arguments\
'(--name -n)'{--name,-n}'[Symbolic name for the new deployment]'\
;;
delete)
_arguments \
$_nixops_common_arguments\
'--all[Delete all deployments in the state file]'\
'--force[]'
;;
deploy)
_arguments \
$_nixops_common_arguments\
'(--kill-obsolete -k)'{--kill-obsolete,-k}'[Destroy machines no longer listed in the deployment specification]'\
$_nix_dry_run \
$_nix_repair \
'--create-only[Create missing machines only: build nothing and do not touch existing machines]'\
'--build-only[Build the configuration without creating or deploying machines]'\
'--copy-only[Do everything except activate the new configuration]'\
'--check[Check that deployed machines are correctly configured]'\
'--allow-reboot[Allow NixOps to reboot the instance if necessary]'\
'--force-reboot[Reboot the machine to activate the new configuration]'\
'--allow-recreate[Recreate resources that have disappeared]'\
$_nixops_include_exclude \
$_nixops_search_path_args \
'--max-concurrent-copy[Set the maximum concurrent nix-copy-closure processes (Default 5)]:Number:( )'
;;
destroy)
_arguments \
$_nixops_common_arguments\
'--all[Destroy all deployments]'\
$_nixops_include_exclude \
;;
stop)
_arguments \
$_nixops_common_arguments\
$_nixops_include_exclude \
;;
start)
_arguments \
$_nixops_common_arguments\
$_nixops_include_exclude \
;;
info)
_arguments \
$_nixops_common_arguments\
'--all[Print information about all resources in all known deployments]'\
'--plain[Print in a more easily parsed format]'\
'--no-eval[Do not evaluate the deployment specification]'
;;
check)
_arguments \
$_nixops_common_arguments\
'--all[Check all machines in all known deployments]'
;;
ssh)
_arguments \
$_nixops_common_arguments\
'--include-keys[]'
;;
ssh-for-each)
_arguments \
$_nixops_common_arguments\
'(--parallel -p)'{--parallel,-p}'[Execute the command on each machine in parallel]'\
$_nixops_include_exclude \
;;
reboot)
_arguments \
$_nixops_common_arguments\
$_nixops_include_exclude \
'--no-wait[Do not wait until the machines have finished rebooting]'
;;
backup)
_arguments \
$_nixops_common_arguments\
$_nixops_include_exclude \
;;
restore)
_arguments \
$_nixops_common_arguments\
$_nixops_include_exclude \
'--devices[Restore only the persistent disks which are mapped to the specified device names]:Device names:( )'\
'--backup-id[Restore the persistent disks of all machines to a given backup except the ones listed here.]:Backup ids:( )'
;;
show-option)
_arguments \
$_nixops_common_arguments\
'--xml[Format output as XML]'\
'1:machine:_hosts'\
'2:option:( )'
;;
set-args)
_arguments \
$_nixops_common_arguments\
'--arg[Set the function argument]:Name:( ):Value:( )'\
'--argstr[Like --arg but the value is a string]:Name:( ):Value:( )'\
'--unset[Remove a previously set function argument]:Name:( )'
;;
show-console-output)
_arguments \
$_nixops_common_arguments\
'1:machine:_hosts'
;;
export)
_arguments \
$_nixops_common_arguments\
'--all[Apply to all deployments]'
;;
import)
_arguments \
$_nixops_common_arguments\
'--include-keys[]'
;;
*)
_arguments \
$_nixops_common_arguments\
;;
esac