From a2b2758e0f60ca341b65b28a6471777759215f22 Mon Sep 17 00:00:00 2001 From: Ruixin Date: Thu, 10 Aug 2017 20:58:23 +0000 Subject: [PATCH] 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 --- src/app/main.c | 37 ++++++++++++++++++++++----- src/app/rpmostree-builtin-compose.c | 3 ++- src/app/rpmostree-builtin-container.c | 8 +++--- src/app/rpmostree-builtin-db.c | 5 +++- src/app/rpmostree-builtin-ex.c | 9 ++++--- src/app/rpmostree-builtin-override.c | 5 +++- src/app/rpmostree-builtins.h | 1 + 7 files changed, 51 insertions(+), 17 deletions(-) diff --git a/src/app/main.c b/src/app/main.c index cd631647..91cdbcd9 100644 --- a/src/app/main.c +++ b/src/app/main.c @@ -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); diff --git a/src/app/rpmostree-builtin-compose.c b/src/app/rpmostree-builtin-compose.c index 43dff6c9..13284acf 100644 --- a/src/app/rpmostree-builtin-compose.c +++ b/src/app/rpmostree-builtin-compose.c @@ -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 diff --git a/src/app/rpmostree-builtin-container.c b/src/app/rpmostree-builtin-container.c index 77a9483d..eb479425 100644 --- a/src/app/rpmostree-builtin-container.c +++ b/src/app/rpmostree-builtin-container.c @@ -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 diff --git a/src/app/rpmostree-builtin-db.c b/src/app/rpmostree-builtin-db.c index 89e4955d..addc5943 100644 --- a/src/app/rpmostree-builtin-db.c +++ b/src/app/rpmostree-builtin-db.c @@ -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; diff --git a/src/app/rpmostree-builtin-ex.c b/src/app/rpmostree-builtin-ex.c index c11d750d..550c197e 100644 --- a/src/app/rpmostree-builtin-ex.c +++ b/src/app/rpmostree-builtin-ex.c @@ -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 } }; /* diff --git a/src/app/rpmostree-builtin-override.c b/src/app/rpmostree-builtin-override.c index 0b7ab76c..32dab4e1 100644 --- a/src/app/rpmostree-builtin-override.c +++ b/src/app/rpmostree-builtin-override.c @@ -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 diff --git a/src/app/rpmostree-builtins.h b/src/app/rpmostree-builtins.h index 8d3ea91d..2ddab303 100644 --- a/src/app/rpmostree-builtins.h +++ b/src/app/rpmostree-builtins.h @@ -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); };