main: add --version flag to show current version

Fixes #317
This commit is contained in:
Julian Bouzas
2022-07-26 16:02:02 -04:00
committed by George Kiagiadakis
parent ca16201034
commit ccf1630f39
3 changed files with 39 additions and 0 deletions

View File

@@ -67,6 +67,26 @@ wp_init (WpInitFlags flags)
g_type_ensure (WP_TYPE_FACTORY); g_type_ensure (WP_TYPE_FACTORY);
} }
/*!
* \brief Gets the WirePlumber library version
* \returns WirePlumber library version
*/
const char *
wp_get_library_version (void)
{
return WIREPLUMBER_VERSION;
}
/*!
* \brief Gets the WirePlumber library API version
* \returns WirePlumber library API version
*/
const char *
wp_get_library_api_version (void)
{
return WIREPLUMBER_API_VERSION;
}
/*! /*!
* \brief Gets the WirePlumber module directory * \brief Gets the WirePlumber module directory
* \returns WirePlumber's module directory * \returns WirePlumber's module directory

View File

@@ -66,6 +66,12 @@ typedef enum {
WP_API WP_API
void wp_init (WpInitFlags flags); void wp_init (WpInitFlags flags);
WP_API
const char * wp_get_library_version (void);
WP_API
const char * wp_get_library_api_version (void);
WP_API WP_API
const gchar * wp_get_module_dir (void); const gchar * wp_get_module_dir (void);

View File

@@ -24,10 +24,13 @@ enum WpExitCode
WP_EXIT_CONFIG = 78, /* configuration error */ WP_EXIT_CONFIG = 78, /* configuration error */
}; };
static gboolean show_version = FALSE;
static gchar * config_file = NULL; static gchar * config_file = NULL;
static GOptionEntry entries[] = static GOptionEntry entries[] =
{ {
{ "version", 'v', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &show_version,
"Show version", NULL },
{ "config-file", 'c', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, &config_file, { "config-file", 'c', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, &config_file,
"The context configuration file", NULL }, "The context configuration file", NULL },
{ NULL } { NULL }
@@ -427,6 +430,16 @@ main (gint argc, gchar **argv)
return WP_EXIT_USAGE; return WP_EXIT_USAGE;
} }
if (show_version) {
g_print ("%s\n"
"Compiled with libwireplumber %s\n"
"Linked with libwireplumber %s\n",
argv[0],
WIREPLUMBER_VERSION,
wp_get_library_version());
return WP_EXIT_OK;
}
if (!config_file) if (!config_file)
config_file = "wireplumber.conf"; config_file = "wireplumber.conf";