app: add more rpm-ostree -h output

This is brought up by https://github.com/projectatomic/rpm-ostree/issues/806.

When user types in rpm-ostree [subcommands] -h, the user can now see
more useful information for the subcommands.

Closes: #916
Approved by: jlebon
This commit is contained in:
Ruixin 2017-08-10 20:58:23 +00:00 committed by Atomic Bot
parent ee1613e4bf
commit a2b2758e0f
7 changed files with 51 additions and 17 deletions

View File

@ -38,46 +38,58 @@ static RpmOstreeCommand commands[] = {
#ifdef HAVE_COMPOSE_TOOLING
{ "compose", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD |
RPM_OSTREE_BUILTIN_FLAG_REQUIRES_ROOT,
rpmostree_builtin_compose },
NULL, rpmostree_builtin_compose },
#endif
{ "cleanup", 0,
"Clear cached/pending data",
rpmostree_builtin_cleanup },
{ "db", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
rpmostree_builtin_db },
NULL, rpmostree_builtin_db },
{ "deploy", RPM_OSTREE_BUILTIN_FLAG_SUPPORTS_PKG_INSTALLS,
"Deploy a specific commit",
rpmostree_builtin_deploy },
{ "rebase", RPM_OSTREE_BUILTIN_FLAG_SUPPORTS_PKG_INSTALLS,
"Switch to a different tree",
rpmostree_builtin_rebase },
{ "rollback", 0,
"Revert to the previously booted tree",
rpmostree_builtin_rollback },
{ "status", 0,
"Get the version of the booted system",
rpmostree_builtin_status },
{ "upgrade", RPM_OSTREE_BUILTIN_FLAG_SUPPORTS_PKG_INSTALLS,
"Perform a system upgrade",
rpmostree_builtin_upgrade },
{ "reload", 0,
"Reload configuration",
rpmostree_builtin_reload },
{ "initramfs", 0,
"Enable or disable local initramfs regeneration",
rpmostree_builtin_initramfs },
{ "install", 0,
"Download and install layered RPM packages",
rpmostree_builtin_install },
{ "uninstall", 0,
"Remove one or more overlay packages",
rpmostree_builtin_uninstall },
/* Legacy aliases */
{ "pkg-add", RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
"Download and install layered RPM packages",
rpmostree_builtin_install },
{ "pkg-remove", RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
"Remove one or more overlay packages",
rpmostree_builtin_uninstall },
{ "rpm", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD |
RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
rpmostree_builtin_db },
NULL, rpmostree_builtin_db },
/* Hidden */
{ "ex", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD |
RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
rpmostree_builtin_ex },
NULL,rpmostree_builtin_ex },
{ "start-daemon", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD |
RPM_OSTREE_BUILTIN_FLAG_REQUIRES_ROOT |
RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
rpmostree_builtin_start_daemon },
"start the daemon process", rpmostree_builtin_start_daemon },
{ NULL }
};
@ -121,7 +133,20 @@ option_context_new_with_commands (RpmOstreeCommandInvocation *invocation,
{
gboolean hidden = (command->flags & RPM_OSTREE_BUILTIN_FLAG_HIDDEN) > 0;
if (!hidden)
g_string_append_printf (summary, "\n %s", command->name);
{
g_string_append_printf (summary, "\n %s", command->name);
if (command->description != NULL)
{
/* add padding for description alignment */
guint max_command_len = 15;
guint pad = max_command_len - strlen (command->name);
for (guint padding_num = 0; padding_num < pad + 2; padding_num++)
g_string_append (summary, " ");
g_string_append_printf (summary, "%s", command->description);
}
}
}
g_option_context_set_summary (context, summary->str);

View File

@ -30,8 +30,9 @@
static RpmOstreeCommand compose_subcommands[] = {
{ "tree", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD | RPM_OSTREE_BUILTIN_FLAG_REQUIRES_ROOT,
"Install packages and commit the result to an OSTree repository",
rpmostree_compose_builtin_tree },
{ NULL, 0, NULL }
{ NULL, 0, NULL, NULL }
};
int

View File

@ -25,13 +25,13 @@
static RpmOstreeCommand container_subcommands[] = {
{ "init", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
rpmostree_container_builtin_init },
NULL, rpmostree_container_builtin_init },
{ "assemble", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
rpmostree_container_builtin_assemble },
NULL, rpmostree_container_builtin_assemble },
/* { "start", rpmostree_container_builtin_start }, */
{ "upgrade", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
rpmostree_container_builtin_upgrade },
{ NULL, 0, NULL }
NULL, rpmostree_container_builtin_upgrade },
{ NULL, 0, NULL, NULL }
};
int

View File

@ -25,12 +25,15 @@
static RpmOstreeCommand rpm_subcommands[] = {
{ "diff", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
"Show package changes between two commits",
rpmostree_db_builtin_diff },
{ "list", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
"List packages within commits",
rpmostree_db_builtin_list },
{ "version", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
"Show rpmdb version of packages within the commits",
rpmostree_db_builtin_version },
{ NULL, 0, NULL }
{ NULL, 0, NULL, NULL }
};
static char *opt_repo;

View File

@ -24,14 +24,15 @@
static RpmOstreeCommand ex_subcommands[] = {
{ "livefs", RPM_OSTREE_BUILTIN_FLAG_REQUIRES_ROOT,
"Apply pending deployment changes to booted deployment",
rpmostree_ex_builtin_livefs },
{ "override", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
rpmostree_ex_builtin_override },
NULL, rpmostree_ex_builtin_override },
{ "unpack", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
rpmostree_ex_builtin_unpack },
NULL, rpmostree_ex_builtin_unpack },
{ "container", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
rpmostree_builtin_container },
{ NULL, 0, NULL }
NULL, rpmostree_builtin_container },
{ NULL, 0, NULL, NULL }
};
/*

View File

@ -25,12 +25,15 @@
static RpmOstreeCommand override_subcommands[] = {
{ "replace", RPM_OSTREE_BUILTIN_FLAG_SUPPORTS_PKG_INSTALLS,
"Remove packages from the base layer",
rpmostree_override_builtin_replace },
{ "remove", RPM_OSTREE_BUILTIN_FLAG_SUPPORTS_PKG_INSTALLS,
"Remove packages from the base layer",
rpmostree_override_builtin_remove },
{ "reset", RPM_OSTREE_BUILTIN_FLAG_SUPPORTS_PKG_INSTALLS,
"Reset currently active package overrides",
rpmostree_override_builtin_reset },
{ NULL, 0, NULL }
{ NULL, 0, NULL, NULL }
};
int

View File

@ -43,6 +43,7 @@ typedef struct RpmOstreeCommandInvocation RpmOstreeCommandInvocation;
struct RpmOstreeCommand {
const char *name;
RpmOstreeBuiltinFlags flags;
const char *description; /* a short decription to describe the functionality */
int (*fn) (int argc, char **argv, RpmOstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error);
};