Skip to content
This repository has been archived by the owner on Mar 28, 2018. It is now read-only.

Commit

Permalink
version: Add command line option to show version information
Browse files Browse the repository at this point in the history
Include config.h to include the package version.
Add command line option to show version information.

Fixes #981

Signed-off-by: Archana Shinde <[email protected]>
  • Loading branch information
amshinde committed Jun 28, 2017
1 parent cfcc9cd commit 4e8f155
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion shim/shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <fcntl.h>
#include <termios.h>

#include "config.h"
#include "utils.h"
#include "log.h"
#include "shim.h"
Expand Down Expand Up @@ -528,6 +529,14 @@ parse_numeric_option(char *input) {
return num;
}

/*
* Print version information.
*/
void
show_version(void) {
printf("%s version: %s (commit: %s)\n", "cc-shim", PACKAGE_VERSION, GIT_COMMIT);
}

/*!
* Print program usage
*/
Expand All @@ -542,6 +551,7 @@ print_usage(void) {
printf(" -d, --debug Enable debug output\n");
printf(" -h, --help Display this help message\n");
printf(" -w, --initial-workload This instance represents the initial workload and will destroy the VM when it finishes\n");
printf(" -v, --version Show version\n");
}

int
Expand Down Expand Up @@ -573,10 +583,11 @@ main(int argc, char **argv)
{"debug", no_argument, 0, 'd'},
{"help", no_argument, 0, 'h'},
{"initial-workload", no_argument, 0, 'w'},
{"version", no_argument, no_argument, 'v'},
{ 0, 0, 0, 0},
};

while ((c = getopt_long(argc, argv, "c:p:o:s:e:dhw", prog_opts, NULL))!= -1) {
while ((c = getopt_long(argc, argv, "c:p:o:s:e:dhwv", prog_opts, NULL))!= -1) {
switch (c) {
case 'c':
shim.container_id = strdup(optarg);
Expand Down Expand Up @@ -613,6 +624,9 @@ main(int argc, char **argv)
case 'w':
shim.initial_workload = true;
break;
case 'v':
show_version();
exit(EXIT_SUCCESS);
case 'h':
print_usage();
exit(EXIT_SUCCESS);
Expand Down

0 comments on commit 4e8f155

Please sign in to comment.