app: provide command description in a better place
Before, when using rpm-ostree -h command, the command description was shown together with the command itself Now, we separate the command description out, providing user a better view of the description. Closes: #916 Approved by: jlebon
This commit is contained in:
parent
a2b2758e0f
commit
534fc30308
@ -38,13 +38,15 @@ static RpmOstreeCommand commands[] = {
|
||||
#ifdef HAVE_COMPOSE_TOOLING
|
||||
{ "compose", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD |
|
||||
RPM_OSTREE_BUILTIN_FLAG_REQUIRES_ROOT,
|
||||
NULL, rpmostree_builtin_compose },
|
||||
"Commands to compose a tree",
|
||||
rpmostree_builtin_compose },
|
||||
#endif
|
||||
{ "cleanup", 0,
|
||||
"Clear cached/pending data",
|
||||
rpmostree_builtin_cleanup },
|
||||
{ "db", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
|
||||
NULL, rpmostree_builtin_db },
|
||||
"Commands to query the RPM database",
|
||||
rpmostree_builtin_db },
|
||||
{ "deploy", RPM_OSTREE_BUILTIN_FLAG_SUPPORTS_PKG_INSTALLS,
|
||||
"Deploy a specific commit",
|
||||
rpmostree_builtin_deploy },
|
||||
@ -74,22 +76,20 @@ static RpmOstreeCommand commands[] = {
|
||||
rpmostree_builtin_uninstall },
|
||||
/* Legacy aliases */
|
||||
{ "pkg-add", RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
|
||||
"Download and install layered RPM packages",
|
||||
rpmostree_builtin_install },
|
||||
NULL, rpmostree_builtin_install },
|
||||
{ "pkg-remove", RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
|
||||
"Remove one or more overlay packages",
|
||||
rpmostree_builtin_uninstall },
|
||||
NULL, rpmostree_builtin_uninstall },
|
||||
{ "rpm", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD |
|
||||
RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
|
||||
NULL, rpmostree_builtin_db },
|
||||
/* Hidden */
|
||||
{ "ex", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD |
|
||||
RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
|
||||
NULL,rpmostree_builtin_ex },
|
||||
"Commands still under experiment", rpmostree_builtin_ex },
|
||||
{ "start-daemon", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD |
|
||||
RPM_OSTREE_BUILTIN_FLAG_REQUIRES_ROOT |
|
||||
RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
|
||||
"start the daemon process", rpmostree_builtin_start_daemon },
|
||||
NULL, rpmostree_builtin_start_daemon },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -124,8 +124,14 @@ option_context_new_with_commands (RpmOstreeCommandInvocation *invocation,
|
||||
g_autoptr(GString) summary = g_string_new (NULL);
|
||||
|
||||
if (invocation)
|
||||
g_string_append_printf (summary, "Builtin \"%s\" Commands:",
|
||||
invocation->command->name);
|
||||
{
|
||||
if (invocation->command->description != NULL)
|
||||
g_string_append_printf (summary, "%s\n\n",
|
||||
invocation->command->description);
|
||||
|
||||
g_string_append_printf (summary, "Builtin \"%s\" Commands:",
|
||||
invocation->command->name);
|
||||
}
|
||||
else /* top level */
|
||||
g_string_append (summary, "Builtin Commands:");
|
||||
|
||||
@ -134,18 +140,9 @@ 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 %-17s", 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_string_append_printf (summary, "%s", command->description);
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,6 +168,16 @@ rpmostree_option_context_parse (GOptionContext *context,
|
||||
invocation ? invocation->command->flags : RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD;
|
||||
gboolean use_daemon = ((flags & RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD) == 0);
|
||||
|
||||
if (invocation && invocation->command->description != NULL)
|
||||
{
|
||||
/* The extra summary explanation is only provided for commands with description */
|
||||
const char* context_summary = g_option_context_get_summary (context);
|
||||
|
||||
/* check whether the summary has been set earlier */
|
||||
if (context_summary == NULL)
|
||||
g_option_context_set_summary (context, invocation->command->description);
|
||||
}
|
||||
|
||||
if (main_entries != NULL)
|
||||
g_option_context_add_main_entries (context, main_entries, NULL);
|
||||
|
||||
|
@ -52,7 +52,7 @@ rpmostree_builtin_cleanup (int argc,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("- Clear cached/pending data");
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("");
|
||||
g_autoptr(GPtrArray) cleanup_types = g_ptr_array_new ();
|
||||
glnx_unref_object RPMOSTreeOS *os_proxy = NULL;
|
||||
glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL;
|
||||
|
@ -25,12 +25,12 @@
|
||||
|
||||
static RpmOstreeCommand container_subcommands[] = {
|
||||
{ "init", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
|
||||
NULL, rpmostree_container_builtin_init },
|
||||
"Initialize a local container", rpmostree_container_builtin_init },
|
||||
{ "assemble", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
|
||||
NULL, rpmostree_container_builtin_assemble },
|
||||
"Assemble a local container", rpmostree_container_builtin_assemble },
|
||||
/* { "start", rpmostree_container_builtin_start }, */
|
||||
{ "upgrade", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
|
||||
NULL, rpmostree_container_builtin_upgrade },
|
||||
"Perform a local container upgrade", rpmostree_container_builtin_upgrade },
|
||||
{ NULL, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
|
@ -68,7 +68,7 @@ rpmostree_builtin_deploy (int argc,
|
||||
const char *const *install_pkgs = NULL;
|
||||
const char *const *uninstall_pkgs = NULL;
|
||||
|
||||
context = g_option_context_new ("REVISION - Deploy a specific commit");
|
||||
context = g_option_context_new ("REVISION");
|
||||
|
||||
if (!rpmostree_option_context_parse (context,
|
||||
option_entries,
|
||||
|
@ -27,11 +27,11 @@ static RpmOstreeCommand ex_subcommands[] = {
|
||||
"Apply pending deployment changes to booted deployment",
|
||||
rpmostree_ex_builtin_livefs },
|
||||
{ "override", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
|
||||
NULL, rpmostree_ex_builtin_override },
|
||||
"Manage base overrides", rpmostree_ex_builtin_override },
|
||||
{ "unpack", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
|
||||
NULL, rpmostree_ex_builtin_unpack },
|
||||
"unpack RPM into local OSTree repo", rpmostree_ex_builtin_unpack },
|
||||
{ "container", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
|
||||
NULL, rpmostree_builtin_container },
|
||||
"Assemble local unprivileged containers", rpmostree_builtin_container },
|
||||
{ NULL, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
|
@ -62,7 +62,7 @@ rpmostree_builtin_initramfs (int argc,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("- Enable or disable local initramfs regeneration");
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("");
|
||||
|
||||
_cleanup_peer_ GPid peer_pid = 0;
|
||||
glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL;
|
||||
|
@ -59,7 +59,7 @@ rpmostree_ex_builtin_livefs (int argc,
|
||||
{
|
||||
_cleanup_peer_ GPid peer_pid = 0;
|
||||
glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL;
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("- Apply pending deployment changes to booted deployment");
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("");
|
||||
if (!rpmostree_option_context_parse (context,
|
||||
option_entries,
|
||||
&argc, &argv,
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
static RpmOstreeCommand override_subcommands[] = {
|
||||
{ "replace", RPM_OSTREE_BUILTIN_FLAG_SUPPORTS_PKG_INSTALLS,
|
||||
"Remove packages from the base layer",
|
||||
"Replace packages in the base layer",
|
||||
rpmostree_override_builtin_replace },
|
||||
{ "remove", RPM_OSTREE_BUILTIN_FLAG_SUPPORTS_PKG_INSTALLS,
|
||||
"Remove packages from the base layer",
|
||||
|
@ -59,7 +59,7 @@ rpmostree_builtin_rebase (int argc,
|
||||
/* forced blank for now */
|
||||
const char *packages[] = { NULL };
|
||||
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("REFSPEC [REVISION] - Switch to a different tree");
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("REFSPEC [REVISION]");
|
||||
glnx_unref_object RPMOSTreeOS *os_proxy = NULL;
|
||||
g_autofree char *transaction_address = NULL;
|
||||
glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL;
|
||||
|
@ -40,7 +40,7 @@ rpmostree_builtin_reload (int argc,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("- Reload configuration");
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("");
|
||||
glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL;
|
||||
_cleanup_peer_ GPid peer_pid = 0;
|
||||
|
||||
|
@ -54,7 +54,7 @@ rpmostree_builtin_rollback (int argc,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
GOptionContext *context = g_option_context_new ("- Revert to the previously booted tree");
|
||||
GOptionContext *context = g_option_context_new ("");
|
||||
glnx_unref_object RPMOSTreeOS *os_proxy = NULL;
|
||||
glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL;
|
||||
g_autofree char *transaction_address = NULL;
|
||||
|
@ -585,7 +585,7 @@ rpmostree_builtin_status (int argc,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("- Get the version of the booted system");
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("");
|
||||
glnx_unref_object RPMOSTreeOS *os_proxy = NULL;
|
||||
glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL;
|
||||
g_autoptr(GVariant) deployments = NULL;
|
||||
|
@ -57,7 +57,7 @@ rpmostree_builtin_upgrade (int argc,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("- Perform a system upgrade");
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("");
|
||||
glnx_unref_object RPMOSTreeOS *os_proxy = NULL;
|
||||
glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL;
|
||||
g_autoptr(GVariant) previous_default_deployment = NULL;
|
||||
|
@ -984,7 +984,7 @@ rpmostree_compose_builtin_tree (int argc,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("TREEFILE - Install packages and commit the result to an OSTree repository");
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("TREEFILE");
|
||||
if (!rpmostree_option_context_parse (context,
|
||||
option_entries,
|
||||
&argc, &argv,
|
||||
|
@ -39,7 +39,7 @@ rpmostree_db_builtin_diff (int argc, char **argv,
|
||||
GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context =
|
||||
g_option_context_new ("COMMIT COMMIT - Show package changes between two commits");
|
||||
g_option_context_new ("COMMIT COMMIT");
|
||||
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
if (!rpmostree_db_option_context_parse (context, option_entries, &argc, &argv, invocation, &repo,
|
||||
|
@ -84,7 +84,7 @@ rpmostree_db_builtin_list (int argc, char **argv,
|
||||
GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context =
|
||||
g_option_context_new ("[PREFIX-PKGNAME...] COMMIT... - List packages within commits");
|
||||
g_option_context_new ("[PREFIX-PKGNAME...] COMMIT...");
|
||||
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
if (!rpmostree_db_option_context_parse (context, option_entries, &argc, &argv,
|
||||
|
@ -89,7 +89,7 @@ rpmostree_db_builtin_version (int argc, char **argv,
|
||||
GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context =
|
||||
g_option_context_new ("COMMIT... - Show rpmdb version of packages within the commits");
|
||||
g_option_context_new ("COMMIT...");
|
||||
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
if (!rpmostree_db_option_context_parse (context, db_version_entries, &argc,
|
||||
|
@ -114,8 +114,7 @@ rpmostree_override_builtin_replace (int argc, char **argv,
|
||||
glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL;
|
||||
_cleanup_peer_ GPid peer_pid = 0;
|
||||
|
||||
context = g_option_context_new ("PACKAGE [PACKAGE...] - "
|
||||
"Remove packages from the base layer");
|
||||
context = g_option_context_new ("PACKAGE [PACKAGE...]");
|
||||
|
||||
if (!rpmostree_option_context_parse (context,
|
||||
option_entries,
|
||||
@ -156,8 +155,7 @@ rpmostree_override_builtin_remove (int argc, char **argv,
|
||||
glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL;
|
||||
_cleanup_peer_ GPid peer_pid = 0;
|
||||
|
||||
context = g_option_context_new ("PACKAGE [PACKAGE...] - "
|
||||
"Remove packages from the base layer");
|
||||
context = g_option_context_new ("PACKAGE [PACKAGE...]");
|
||||
|
||||
if (!rpmostree_option_context_parse (context,
|
||||
option_entries,
|
||||
@ -198,8 +196,7 @@ rpmostree_override_builtin_reset (int argc, char **argv,
|
||||
glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL;
|
||||
_cleanup_peer_ GPid peer_pid = 0;
|
||||
|
||||
context = g_option_context_new ("PACKAGE [PACKAGE...] - "
|
||||
"Reset currently active package overrides");
|
||||
context = g_option_context_new ("PACKAGE [PACKAGE...]");
|
||||
|
||||
g_option_context_add_main_entries (context, reset_option_entries, NULL);
|
||||
|
||||
|
@ -154,7 +154,7 @@ rpmostree_builtin_install (int argc,
|
||||
glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL;
|
||||
_cleanup_peer_ GPid peer_pid = 0;
|
||||
|
||||
context = g_option_context_new ("PACKAGE [PACKAGE...] - Download and install layered RPM packages");
|
||||
context = g_option_context_new ("PACKAGE [PACKAGE...]");
|
||||
|
||||
g_option_context_add_main_entries (context, uninstall_option_entry, NULL);
|
||||
|
||||
@ -197,7 +197,7 @@ rpmostree_builtin_uninstall (int argc,
|
||||
glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL;
|
||||
_cleanup_peer_ GPid peer_pid = 0;
|
||||
|
||||
context = g_option_context_new ("PACKAGE [PACKAGE...] - Remove one or more overlay packages");
|
||||
context = g_option_context_new ("PACKAGE [PACKAGE...]");
|
||||
|
||||
g_option_context_add_main_entries (context, install_option_entry, NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user