File: dnf

package info (click to toggle)
yash 2.43-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 7,184 kB
  • ctags: 3,159
  • sloc: ansic: 31,766; makefile: 812; sh: 407; sed: 16
file content (228 lines) | stat: -rw-r--r-- 6,171 bytes parent folder | download | duplicates (4)
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# (C) 2016 magicant

# Completion script for the "dnf" command.
# Supports dnf 1.1.9.

function completion/dnf {

	typeset OPTIONS ARGOPT PREFIX
	OPTIONS=( #>#
	"4; use IPv4 addresses only"
	"6; use IPv6 addresses only"
	"--allowerasing; allow erasing conflicting packages"
	"--assumeno; reject all questions"
	"b --best; consider latest packages only"
	"C --cacheonly; use local system cache only"
	"c: --config:; specify a config file"
	"d: --debuglevel:" # deprecated
	"--debugsolver"
	"--disableexcludes:; disable excludes for the specified repo"
	"--disablerepo:"
	"--downloadonly"
	"e: --errorlevel:" # deprecated
	"--enablerepo:"
	"x: --exclude:; specify packages to exclude"
	"h --help; print help"
	"--installroot:"
	"--nogpgcheck; skip GPG check"
	"--noplugins; disable all plugins"
	"q --quiet; don't print progress"
	"R: --randomwait:; specify max minutes to wait"
	"--refresh; refresh metadata"
	"--releasever:; assume the specified system release version"
	"--repofrompath:; temporarily add the specified repository"
	"--rpmverbosity:; debug output level of the rpm command"
	"--setopt:; override a config option"
	"--showduplicates"
	"v --verbose; print debug messages"
	"--version; print version info"
	"--assumeyes; accept all questions"
	) #<#

	command -f completion//parseoptions -es
	case $ARGOPT in
		(-)
			command -f completion//completeoptions
			;;
		('')
			# find first non-option argument and
			# parse some global options
			typeset OPTIND=2 subcmd=
			while [ $OPTIND -le ${WORDS[#]} ]; do
				case ${WORDS[OPTIND]} in
					(-?*)
						;;
					(*)
						subcmd=${WORDS[OPTIND]}
						break
						;;
				esac
				OPTIND=$((OPTIND+1))
			done

			if [ $OPTIND -le ${WORDS[#]} ]; then
				# complete command argument
				typeset OLDWORDS
				OLDWORDS=("$WORDS")
				WORDS=("${WORDS[1]}" "${WORDS[OPTIND+1,-1]}")
				if { command -vf "completion/dnf::$subcmd:arg" ||
						. -AL "completion/dnf_$subcmd"; } >/dev/null 2>&1; then
					command -f "completion/dnf::$subcmd:arg" 
				else
					# Unknown subcommand... This fallback should work for most subcommands.
					command -f completion/dnf::completepackage available
					complete -P "$PREFIX" -f
				fi
			else
				command -f completion/dnf::completecmd
			fi
			;;
	esac

}

function completion/dnf::completion_helper {
	${$(head -n 1 -- "$(command -v dnf)")#\#!} -m dnf.cli.completion_helper "$@"
} 2>/dev/null

function completion/dnf::complete_by_helper {
	typeset IFS='
'
	complete -P "$PREFIX" $(command -f completion/dnf::completion_helper "$@")
}

function completion/dnf::completecmd {
	command -f completion/dnf::complete_by_helper _cmds "${TARGETWORD#"$PREFIX"}"
}

# $1 = installed, available, updates
function completion/dnf::completepackage {
	command -f completion/dnf::complete_by_helper list -Cq "$1" "${TARGETWORD#"$PREFIX"}"
}

function completion/dnf::check-update:arg {
	command -f completion/dnf::completepackage installed
}

function completion/dnf::clean:arg {
	command -f completion/dnf::complete_by_helper clean -Cq DUMMY "${TARGETWORD#"$PREFIX"}"
}

function completion/dnf::distro-sync:arg {
	command -f completion/dnf::completepackage installed
}

function completion/dnf::distribution-synchronization:arg {
	command -f completion/dnf::completepackage installed
}

function completion/dnf::downgrade:arg {
	command -f completion/dnf::complete_by_helper downgrade -Cq "${TARGETWORD#"$PREFIX"}"
}

function completion/dnf::erase:arg {
	command -f completion/dnf::complete_by_helper remove -Cq "${TARGETWORD#"$PREFIX"}"
}

# TODO
#function completion/dnf::group:arg {
#}

function completion/dnf::help:arg {
	command -f completion/dnf::completecmd
}

function completion/dnf::history:arg {
	command -f completion/dnf::complete_by_helper history -Cq DUMMY "${TARGETWORD#"$PREFIX"}"
	# TODO complete second operand
}

function completion/dnf::info:arg {
	command -f completion/dnf::completepackage available
}

function completion/dnf::install:arg {
	command -f completion/dnf::complete_by_helper install -Cq "${TARGETWORD#"$PREFIX"}"
}

function completion/dnf::list:arg
	case ${WORDS[#]} in
		(1)
			command -f completion/dnf::complete_by_helper list -Cq DUMMY "${TARGETWORD#"$PREFIX"}"
			;;
		(*)
			command -f completion/dnf::completepackage available
			;;
	esac

function completion/dnf::makecache:arg { #>>#
	complete -P "$PREFIX" timer
} #<<#

function completion/dnf::mark:arg
	case ${WORDS[#]} in
		(1) #>>#
			complete -P "$PREFIX" install remove
			;; #<<#
		(*)
			command -f completion/dnf::completepackage installed
			;;
	esac

function completion/dnf::provides:arg {
	complete -P "$PREFIX" -f
}

function completion/dnf::reinstall:arg {
	command -f completion/dnf::complete_by_helper reinstall -Cq "${TARGETWORD#"$PREFIX"}"
}

function completion/dnf::remove:arg {
	command -f completion/dnf::complete_by_helper remove -Cq "${TARGETWORD#"$PREFIX"}"
}

function completion/dnf::repolist:arg { #>>#
	complete -P "$PREFIX" all enabled disabled
} #<<#

# TODO
#function completion/dnf::repository-packages:arg {
#}

# TODO
#function completion/dnf::search:arg {
#}

function completion/dnf::update:arg {
	command -f completion/dnf::upgrade:arg "$@"
}

function completion/dnf::updateinfo:arg { #>>#
	complete -P "$PREFIX" -D 'show advisories on all package versions' all
	complete -P "$PREFIX" -D 'show advisories on newer packages' available
	complete -P "$PREFIX" -D 'print detail' info
	complete -P "$PREFIX" -D 'show advisories on installed or older packages' installed
	complete -P "$PREFIX" -D 'list update advisories' list
	complete -P "$PREFIX" -D 'just print number of updates' summary
	complete -P "$PREFIX" -D 'show advisories on available newer packages' updates
	#<<#
	command -f completion/dnf::completepackage updates
}

function completion/dnf::upgrade:arg {
	command -f completion/dnf::completepackage updates
}

function completion/dnf::update-to:arg {
	command -f completion/dnf::upgrade-to:arg "$@"
}

function completion/dnf::upgrade-to:arg {
	command -f completion/dnf::completepackage updates
}

function completion/dnf::whatprovides:arg {
	command -f completion/dnf::provides:arg "$@"
}

# vim: set ft=sh ts=8 sts=8 sw=8 noet: