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

Commit

Permalink
Merge pull request #1020 from amshinde/show-shim-version
Browse files Browse the repository at this point in the history
version: Add command line option to show version information
  • Loading branch information
jodh-intel authored Jun 29, 2017
2 parents cfcc9cd + 4e8f155 commit 490db9c
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 490db9c

Please sign in to comment.