summaryrefslogtreecommitdiff
path: root/contrib/completion/zsh/_devtools.in
blob: 959497e11a7430c8b9bf4a633bba3badadb92a4e (plain)
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
#compdef archbuild pkgrepo arch-nspawn archrelease commitpkg pkgctl diffpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-x86_64-build=archbuild testing-x86_64-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-x86_64-build=archbuild checkpkg sogrep offload-build makerepropkg
#
# SPDX-License-Identifier: GPL-3.0-or-later

m4_include(lib/valid-tags.sh)
m4_include(lib/valid-repos.sh)

_binary_arch=${_arch[*]:0:-1}
_colors=(never always auto)

_archbuild_args=(
	'-c[Recreate the chroot before building]'
	'-r[Create chroots in this directory]:base_dir:_files -/'
	'-h[Display usage]'
	'--[Introduce makechrootpkg options]:*::makechrootpkg options:=  _dispatch makechrootpkg makechrootpkg'
)

_pkgrepo_cmds=(
	"pkgrepo command"
	"clone[Clone a package repository]"
	"configure[Configure a clone according to distro specs]"
	"web[Open the packaging repository's website]"
)

_pkgrepo_clone_args=(
	'(-m --maintainer=)'{-m,--maintainer=}'[Clone all packages of the named maintainer]:maintainer:'
	'(-u --unprivileged)'{-u,--unprivileged}'[Read-only access without packager info as Git author]'
	'--universe[Clone all existing packages, useful for cache warming]'
	'(-h --help)'{-h,--help}'[Display usage]'
	'*:packages:_devtools_completions_all_packages'
)

_pkgrepo_configure_args=(
	'(-u --unprivileged)'{-u,--unprivileged}'[Configure read-only repo without packager info as Git author]'
	'(-h --help)'{-h,--help}'[Display usage]'
	'*:git_dir:_files -/'
)

_pkgrepo_web_args=(
	'(-h --help)'{-h,--help}'[Display usage]'
	'*:git_dir:_files -/'
)

_arch_nspawn_args=(
	'-C[Location of a pacman config file]:pacman_config:_files -g "*.conf(.)"'
	'-M[Location of a makepkg config file]:makepkg_config:_files -g "*.conf(.)"'
	'-c[Set pacman cache]:pacman_cache:_files -/'
	'-f[Copy file from the host to the chroot]:copy_file:_files'
	'-s[Do not run setarch]'
	'-h[Display usage]'
	'1:chroot_dir:_files -/'
)

_archrelease_args=(
	'-f[Force release without checks]'
	"*:arch:($_tags[*])"
)

_commitpkg_args=(
	'-f[Force release without checks]'
	'-s[Target repo server]'
	'-l[Set bandwidth limit]:limit'
	"-a[Release to a specific architecture only]:arch:($_arch[*])"
	'1:commit_msg'
)

_diffpkg_args=(
	'(-l --list)'{-l,--list}'[Tar content list diff mode]'
	'(-d --diffoscope)'{-d,--diffoscope}'[Diffoscope diff mode]'
	'(-p --pkginfo)'{-p,--pkginfo}'[.PKGINFO diff mode]'
	'(-b --buildinfo)'{-b,--buildinfo}'[.BUILDINFO diff mode]'
	'(-m --makepkg-config)'{-m,--makepkg-config}'[Location of a makepkg config file]:makepkg_config:_files -g "*.conf(.)"'
	'(-u -U --unified)'{-u,-U,--unified}'[Output 3 lines of unified context]'
	'(-y --side-by-side)'{-y,--side-by-side}'[Output in two columns]'
	'--color=[Color output]:when:($_colors[*])'
	'(-W --width=)'{-W,--width=}'[Output at most NUM print columns]:num:(auto columns)'
	'(-P --pool=)'{-P,--pool=}'[pool directory]:dir:_files -/'
	'(-v --verbose)'{-v,--verbose}'[Provide more detailed/unfiltered output]'
	'(-h --help)'{-h,--help}'[Display usage]'
	'*:packages:_devtools_completions_all_packages'
)

_finddeps_args=(
	'1:packages:_devtools_completions_all_packages'
)

_makechrootpkg_args=(
	'-h[Display usage]'
	'-c[Clean the chroot before building]'
	'-d[Bind directory into build chroot as read-write]:bind_dir_rw:_files -/'
	'-D[Bind directory into build chroot as read-only]:bind_dir_ro:_files -/'
	'-u[Update the working copy of the chroot before building]'
	'-r[The chroot dir to use]:chroot_dir:_files -/'
	'-I[Install a package into the working copy]:target:_files -g "*.pkg.tar.*(.)"'
	'-l[The directory to use as the working copy]:copy_dir:_files -/'
	'-n[Run namcap on the package]'
	'-T[Build in a temporary directory]'
	'-U[Run makepkg as a specified user]:makepkg_user'
)

_mkarchroot_args=(
	'-U[Install a package into the working copy]:target:_files -g "*.pkg.tar.*(.)"'
	'-C[Location of a pacman config file]:pacman_config:_files -g "*.conf(.)"'
	'-M[Location of a makepkg config file]:makepkg_config:_files -g "*.conf(.)"'
	'-c[Set pacman cache]:pacman_cache:_files -/'
	'-h[Display usage]'
	'1:working_dir:_files -/'
	'*:packages:_devtools_completions_all_packages'
)

_rebuildpkgs_args=(
	'1:chroot_dir:_files -/'
	'*:packages:_devtools_completions_all_packages'
)

_checkpkg_args=(
	'(-r --rmdir)'{-r,--rmdir}'[Remove the temporary directory]'
	'(-w --warn)'{-w,--warn}'[Print a warning in case of differences]'
	'(-M --makepkg-config)'{-M,--makepkg-config}'[Location of a makepkg config file]:makepkg_config:_files -g "*.conf(.)"'
	'(-h --help)'{-h,--help}'[Display usage]'
)

_sogrep_args=(
	'(-v --verbose)'{-v,--verbose}'[Show matched links in addition to pkgname]'
	'(-r --refresh)'{-r,--refresh}'[Refresh the links databases]'
	'(-h --help)'{-h,--help}'[Display usage]'
	'1:repo:(all $_repos[*])'
	'2:libname'
)

_offload_build_args=(
	'(-r --repo)'{-r,--repo}'[Build against a specific repository]:repo:($_build_repos[*])'
	'(-a --arch)'{-a,--arch}'[Build against a specific architecture]:arch:(${_binary_arch[*]})'
	'(-s --server)'{-s,--server}'[Offload to a specific Build server]:server:'
	'(-h --help)'{-h,--help}'[Display usage]'
)

_makerepropkg_args=(
	'-d[Run diffoscope if the package is unreproducible]'
	'-c[Set pacman cache]:pacman_cache:_files -/'
	'-M[Location of a makepkg config file]:makepkg_config:_files -g "*.conf(.)"'
	'-h[Display usage]'
	'*:working_dir:_files -g "*.pkg.tar.*(.)"'
)

_devtools_completions_all_packages() {
	typeset -U packages
	packages=($(_call_program packages pacman -Sql))
	compadd - "${(@)packages}"
}

_pkgctl_cmds=(
	"pkgctl command"
	"diff[Compare package files using different modes]"
	"repo[Manage Git packaging repositories and their configuration]"
)

_pkgctl_diff_args=("${_diffpkg_args[@]}")

_pkgctl_repo_cmds=("${_pkgrepo_cmds[@]}")
_pkgctl_repo_clone_args=("${_pkgrepo_clone_args[@]}")
_pkgctl_repo_configure_args=("${_pkgrepo_configure_args[@]}")

_handle_subcommands() {
	local service_name=${1}
	if typeset -p ${service_name}_cmds &> /dev/null; then
		_arguments -C \
			"1: :->cmds" \
			'*::arg:->args'
		case $state in
			cmds)
				local service_cmds=${service_name}_cmds[@]
				_values "${(P)service_cmds}"
				;;
			args)
				local service_sub=${service_name}_$line[1]
				if typeset -p ${service_sub}_args &> /dev/null; then
					local cmd_args=${service_sub}_args[@]
					_arguments -s "${(P)cmd_args}"
				elif typeset -p ${service_sub}_cmds &> /dev/null; then
					_handle_subcommands "${service_sub}"
				fi
				;;
		esac
	elif typeset -p ${service_name}_args &> /dev/null; then
		local argname="${service_name}_args[@]"
		_arguments -s "${(P)argname}"
	fi
}

_devtools() {
	_handle_subcommands _${service//-/_}
}

_devtools