_gb 3.01 KB
Newer Older
1
2
3
#compdef gb
#autoload

4
5
6
_gb () {
	local ret=1 state
	_arguments -C ':command:->command' '*::options:->options' && ret=0
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
	case $state in
	(command)
		local -a subcommands
		subcommands=(
			"build:build a package"
			"doc:show documentation for a package or symbol"
			"env:print project environment variables"
			"generate:generate Go files by processing source"
			"help:displays the help"
			"info:info returns information about this project"
			"list:list the packages named by the importpaths"
			"test:test packages"
			"vendor:manage your vendored dependencies"
		)
		_describe -t subcommands 'gb subcommands' subcommands && ret=0
		;;
	(options)
		case $line[1] in
		(build)
			_arguments \
				-f'[ignore cached packages]' \
				-F'[do not cache packages]' \
				-q'[decreases verbosity]' \
				-P'[the number of build jobs to run in parallel]' \
				-R'[sets the base of the project root search path]' \
				-dotfile'[output a dot formatted file of the build steps]' \
				-ldflags'["flag list" arguments to pass to the linker]' \
				-gcflags'["arg list" arguments to pass to the compiler]' \
				-race'[enable data race detection]' \
				-tags'["tag list" additional build tags]'
			;;
		(list)
			_arguments \
				-f'[alternate format for the list, using the syntax of package template]' \
				-s'[read format template from STDIN]' \
				-json'[prints output in structured JSON format]'
			;;
		(test)
			_arguments \
				-v'[print output from test subprocess]' \
				-ldflags'["flag list" arguments to pass to the linker]' \
				-gcflags'["arg list" arguments to pass to the compiler]' \
				-race'[enable data race detection]' \
				-tags'["tag list" additional build tags]'
			;;
		(vendor)
			_gb-vendor
		esac
		;;
	esac
58

59
	return ret
60
61
}

62
63
64
_gb-vendor () {
	local curcontext="$curcontext" state line
	_arguments -C ':command:->command' '*::options:->options'
65
66

	case $state in
67
68
69
70
71
72
73
74
75
76
77
	(command)
		local -a subcommands
		subcommands=(
			'delete:deletes a local dependency'
			'fetch:fetch a remote dependency'
			'list:lists dependencies, one per line'
			'purge:remove all unreferenced dependencies'
			'restore:restore dependencies from the manifest'
			'update:update a local dependency'
		)
		_describe -t subcommands 'gb vendor subcommands' subcommands && ret=0
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
	(options)
		case $line[1] in
			(delete)
				_arguments \
					-all'[remove all dependencies]'
				;;
			(fetch)
				_arguments \
					-branch'[fetch from a particular branch]' \
					-no-recurse'[do not fetch recursively]' \
					-tag'[fetch the specified tag]' \
					-revision'[fetch the specific revision from the branch (if supplied)]' \
					-precaire'[allow the use of insecure protocols]' \
				;;
			(list)
				_arguments \
					-f'[controls the template used for printing each manifest entry]'
				;;
			(restore)
				_arguments \
					-precaire'[allow the use of insecure protocols]'
				;;
			(update)
				_arguments \
					-all'[update all dependencies in the manifest or supply a given dependency]' \
					-precaire'[allow the use of insecure protocols]'
				;;
		esac
107
108
109
		;;
	esac
}
110
111

_gb