Skip to content

Commit

Permalink
cmd/flux-version: add --remote option
Browse files Browse the repository at this point in the history
If --remote option is given, connect to broker and
get 'version' attribute

Fixes flux-framework#1810
  • Loading branch information
garlick committed Nov 8, 2018
1 parent 9a66c93 commit 727049b
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/cmd/builtin/version.c
Expand Up @@ -28,10 +28,26 @@

static int cmd_version (optparse_t *p, int ac, char *av[])
{
printf ("%s-%s\n", PACKAGE_NAME, PACKAGE_VERSION);
const char *version = PACKAGE_VERSION;

if (optparse_hasopt (p, "remote")) {
flux_t *h = builtin_get_flux_handle (p);
if (!h)
log_err_exit ("flux_open");
if (!(version = flux_attr_get (h, "version", NULL)))
log_err_exit ("flux_attr_get");
}

printf ("%s-%s\n", PACKAGE_NAME, version);
return (0);
}

static struct optparse_option version_opts[] = {
{ .name = "remote", .key = 'r', .has_arg = 0,
.usage = "Connect to flux broker for version", },
OPTPARSE_TABLE_END,
};

int subcommand_version_register (optparse_t *p)
{
optparse_err_t e;
Expand All @@ -41,7 +57,7 @@ int subcommand_version_register (optparse_t *p)
NULL,
"Display flux version information",
0,
NULL);
version_opts);
return (e == OPTPARSE_SUCCESS ? 0 : -1);
}

Expand Down

0 comments on commit 727049b

Please sign in to comment.