|
@@ -148,11 +148,21 @@ static int cmd_open(char *cmd, int *pid) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void print_version()
|
|
|
+{
|
|
|
+#ifdef VERSION
|
|
|
+ printf("qcmd version %s\n", VERSION);
|
|
|
+#else
|
|
|
+ printf("qcmd (unknown version)\n");
|
|
|
+#endif
|
|
|
+}
|
|
|
+
|
|
|
void print_help()
|
|
|
{
|
|
|
printf(
|
|
|
"usage: qcmd [options] [command]\n"
|
|
|
" -h, --help Display this help text.\n"
|
|
|
+ " -v, --version Display version information.\n"
|
|
|
" -r, --rows Number of rows in terminal output.\n"
|
|
|
" -c, --cols Number of columns in terminal output.\n"
|
|
|
" -C, --close-on-exit Close the notification on command exit.\n"
|
|
@@ -172,11 +182,12 @@ int main(int argc, char *argv[])
|
|
|
while (1) {
|
|
|
static struct option long_options[] = {
|
|
|
{"help", no_argument, 0, 'h'},
|
|
|
+ {"version", no_argument, 0, 'v'},
|
|
|
{"close-on-exit", no_argument, 0, 'C'},
|
|
|
{0, 0, 0, 0},
|
|
|
};
|
|
|
|
|
|
- c = getopt_long(argc, argv, "hCc:r:", long_options, &option_index);
|
|
|
+ c = getopt_long(argc, argv, "hvCc:r:", long_options, &option_index);
|
|
|
|
|
|
if (c == -1) {
|
|
|
break;
|
|
@@ -186,7 +197,9 @@ int main(int argc, char *argv[])
|
|
|
case 'h':
|
|
|
print_help();
|
|
|
return EXIT_SUCCESS;
|
|
|
-
|
|
|
+ case 'v':
|
|
|
+ print_version();
|
|
|
+ return EXIT_SUCCESS;
|
|
|
case 'C':
|
|
|
state.close_on_exit = 1;
|
|
|
break;
|