cli: add --version command line option

This commit is contained in:
Christian Hergert
2016-04-14 03:31:33 -07:00
parent fe5750f95b
commit bdf888f556

View File

@ -88,11 +88,13 @@ main (gint argc,
GError *error = NULL; GError *error = NULL;
GSource *gsource; GSource *gsource;
gchar *command = NULL; gchar *command = NULL;
gboolean version = FALSE;
int pid = -1; int pid = -1;
int fd; int fd;
GOptionEntry entries[] = { GOptionEntry entries[] = {
{ "pid", 'p', 0, G_OPTION_ARG_INT, &pid, N_("Make sysprof specific to a task"), N_("PID") }, { "pid", 'p', 0, G_OPTION_ARG_INT, &pid, N_("Make sysprof specific to a task"), N_("PID") },
{ "command", 'c', 0, G_OPTION_ARG_STRING, &command, N_("Run a command and profile the process"), N_("COMMAND") }, { "command", 'c', 0, G_OPTION_ARG_STRING, &command, N_("Run a command and profile the process"), N_("COMMAND") },
{ "version", 0, 0, G_OPTION_ARG_NONE, &version, N_("Print the sysprof-cli version and exit") },
{ NULL } { NULL }
}; };
@ -107,6 +109,12 @@ main (gint argc,
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (version)
{
g_print ("Sysprof "PACKAGE_VERSION"\n");
return EXIT_SUCCESS;
}
if (argc > 2) if (argc > 2)
{ {
gint i; gint i;