Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add -V, --version option

  • Loading branch information...
commit 7597dd67ce455abc8d40a0f29977de5d5dfa66f5 1 parent 9e5ddcb
@falconindy authored
Showing with 16 additions and 4 deletions.
  1. +2 −2 extra/bash-completion
  2. +2 −0  extra/zsh-completion
  3. +12 −2 src/pkgfile.c
View
4 extra/bash-completion
@@ -6,8 +6,8 @@ _pkgfile() {
_get_comp_words_by_ref cur prev
opts="-l --list -s --search -u --update -b --binaries -g --glob -i
- --ignorecase -q --quiet -R --repo -r --regex -h --help -v --verbose
- -w --raw -z --compress"
+ --ignorecase -q --quiet -R --repo -r --regex -h --help -V --version
+ -v --verbose -w --raw -z --compress"
if [[ $prev = -*R || $prev = '--repo' ]]; then
repos=$(sed '/^\[\(.*\)\]$/!d;s//\1/g;/options/d' /etc/pacman.conf)
View
2  extra/zsh-completion
@@ -33,6 +33,7 @@ _longopts=(
'--quiet[output less when listing]'
'--repo[search a specific repo]: :_repos'
'--regex[enable matching with regular expressions]'
+ '--version[display program version]'
'--verbose[output more]'
'--raw[disable output justification]'
'--null[null terminate output]'
@@ -51,6 +52,7 @@ _shortopts=(
'*-q[output less when listing]'
'*-R[search a specific repo]: :_repos'
'*-r[enable matching with regular expressions]'
+ '*-V[display program version]'
'*-v[output more]'
'*-w[disable output justification]'
'*-0[null terminate output]'
View
14 src/pkgfile.c
@@ -426,14 +426,20 @@ static void usage(void)
stdout);
fputs(
" General:\n"
- " -h, --help display this help and exit\n\n",
+ " -h, --help display this help and exit\n"
+ " -V, --version display the version and exit\n\n",
stdout);
}
+static void print_version(void)
+{
+ fputs(PACKAGE_NAME " v" PACKAGE_VERSION "\n", stdout);
+}
+
static int parse_opts(int argc, char **argv)
{
int opt;
- static const char *shortopts = "0bdghilqR:rsuvwz::";
+ static const char *shortopts = "0bdghilqR:rsuVvwz::";
static const struct option longopts[] = {
{"binaries", no_argument, 0, 'b'},
{"compress", optional_argument, 0, 'z'},
@@ -447,6 +453,7 @@ static int parse_opts(int argc, char **argv)
{"regex", no_argument, 0, 'r'},
{"search", no_argument, 0, 's'},
{"update", no_argument, 0, 'u'},
+ {"version", no_argument, 0, 'V'},
{"verbose", no_argument, 0, 'v'},
{"raw", no_argument, 0, 'w'},
{"null", no_argument, 0, '0'},
@@ -509,6 +516,9 @@ static int parse_opts(int argc, char **argv)
case 'u':
config.doupdate++;
break;
+ case 'V':
+ print_version();
+ exit(EXIT_SUCCESS);
case 'v':
config.verbose = true;
break;
Please sign in to comment.
Something went wrong with that request. Please try again.