conmon: add new option --version

Print the version and exit immediately.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2018-02-22 20:04:12 +01:00
parent 96a9afedf6
commit 6a23a293d7
No known key found for this signature in database
GPG key ID: 263D6DF2E163E1EA
2 changed files with 12 additions and 1 deletions

View file

@ -97,6 +97,7 @@ static inline void strv_cleanup(char ***strv)
#define DEFAULT_SOCKET_PATH "/var/lib/crio"
static bool opt_version = false;
static bool opt_terminal = false;
static bool opt_stdin = false;
static bool opt_leave_stdin_open = false;
@ -135,6 +136,7 @@ static GOptionEntry opt_entries[] =
{ "timeout", 'T', 0, G_OPTION_ARG_INT, &opt_timeout, "Timeout in seconds", NULL },
{ "log-size-max", 0, 0, G_OPTION_ARG_INT64, &opt_log_size_max, "Maximum size of log file", NULL },
{ "socket-dir-path", 0, 0, G_OPTION_ARG_STRING, &opt_socket_path, "Location of container attach sockets", NULL },
{ "version", 0, 0, G_OPTION_ARG_NONE, &opt_version, "Print the version and exit", NULL },
{ NULL }
};
@ -1119,6 +1121,10 @@ int main(int argc, char *argv[])
g_print("option parsing failed: %s\n", error->message);
exit(1);
}
if (opt_version) {
g_print("conmon version " VERSION "\ncommit: " GIT_COMMIT "\n");
exit(0);
}
if (opt_cid == NULL)
nexit("Container ID not provided. Use --cid");