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

Commit 490db9c

Browse files
author
James O. D. Hunt
authored
Merge pull request #1020 from amshinde/show-shim-version
version: Add command line option to show version information
2 parents cfcc9cd + 4e8f155 commit 490db9c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

shim/shim.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <fcntl.h>
3434
#include <termios.h>
3535

36+
#include "config.h"
3637
#include "utils.h"
3738
#include "log.h"
3839
#include "shim.h"
@@ -528,6 +529,14 @@ parse_numeric_option(char *input) {
528529
return num;
529530
}
530531

532+
/*
533+
* Print version information.
534+
*/
535+
void
536+
show_version(void) {
537+
printf("%s version: %s (commit: %s)\n", "cc-shim", PACKAGE_VERSION, GIT_COMMIT);
538+
}
539+
531540
/*!
532541
* Print program usage
533542
*/
@@ -542,6 +551,7 @@ print_usage(void) {
542551
printf(" -d, --debug Enable debug output\n");
543552
printf(" -h, --help Display this help message\n");
544553
printf(" -w, --initial-workload This instance represents the initial workload and will destroy the VM when it finishes\n");
554+
printf(" -v, --version Show version\n");
545555
}
546556

547557
int
@@ -573,10 +583,11 @@ main(int argc, char **argv)
573583
{"debug", no_argument, 0, 'd'},
574584
{"help", no_argument, 0, 'h'},
575585
{"initial-workload", no_argument, 0, 'w'},
586+
{"version", no_argument, no_argument, 'v'},
576587
{ 0, 0, 0, 0},
577588
};
578589

579-
while ((c = getopt_long(argc, argv, "c:p:o:s:e:dhw", prog_opts, NULL))!= -1) {
590+
while ((c = getopt_long(argc, argv, "c:p:o:s:e:dhwv", prog_opts, NULL))!= -1) {
580591
switch (c) {
581592
case 'c':
582593
shim.container_id = strdup(optarg);
@@ -613,6 +624,9 @@ main(int argc, char **argv)
613624
case 'w':
614625
shim.initial_workload = true;
615626
break;
627+
case 'v':
628+
show_version();
629+
exit(EXIT_SUCCESS);
616630
case 'h':
617631
print_usage();
618632
exit(EXIT_SUCCESS);

0 commit comments

Comments
 (0)