xdg-app: Update the command names and make nicer usage output

All the *-remote commands are changed to remote-* and otherwise made
more regulare.

The usage output is split into titled subsections and has per-command
descriptions.
tingping/wmclass
Alexander Larsson 2016-01-13 16:09:30 +01:00
parent f7a1fdaa99
commit 123626b36f
3 changed files with 56 additions and 34 deletions

View File

@ -40,7 +40,7 @@ static GOptionEntry options[] = {
gboolean gboolean
xdg_app_builtin_repo_update (int argc, char **argv, GCancellable *cancellable, GError **error) xdg_app_builtin_build_update_repo (int argc, char **argv, GCancellable *cancellable, GError **error)
{ {
g_autoptr(GOptionContext) context = NULL; g_autoptr(GOptionContext) context = NULL;
g_autoptr(GFile) repofile = NULL; g_autoptr(GFile) repofile = NULL;

View File

@ -67,7 +67,7 @@ BUILTINPROTO(build);
BUILTINPROTO(build_finish); BUILTINPROTO(build_finish);
BUILTINPROTO(build_export); BUILTINPROTO(build_export);
BUILTINPROTO(build_bundle); BUILTINPROTO(build_bundle);
BUILTINPROTO(repo_update); BUILTINPROTO(build_update_repo);
BUILTINPROTO(export_file); BUILTINPROTO(export_file);
BUILTINPROTO(override); BUILTINPROTO(override);

View File

@ -38,42 +38,54 @@ static gboolean opt_user;
typedef struct { typedef struct {
const char *name; const char *name;
gboolean (*fn) (int argc, char **argv, GCancellable *cancellable, GError **error); gboolean (*fn) (int argc, char **argv, GCancellable *cancellable, GError **error);
const char *description;
gboolean deprecated; gboolean deprecated;
} XdgAppCommand; } XdgAppCommand;
static XdgAppCommand commands[] = { static XdgAppCommand commands[] = {
{ "run", xdg_app_builtin_run }, { " Manage installed apps and runtimes" },
{ "install", xdg_app_builtin_install }, { "install", xdg_app_builtin_install, "Install an application or runtime from a remote"},
{ "update", xdg_app_builtin_update }, { "update", xdg_app_builtin_update, "Update an installed application or runtime"},
{ "uninstall", xdg_app_builtin_uninstall }, { "uninstall", xdg_app_builtin_uninstall, "Uninstall an installed application or runtime" },
{ "make-current", xdg_app_builtin_make_current_app }, { "list-runtimes", xdg_app_builtin_list_runtimes, "List installed runtimes" },
{ "enter", xdg_app_builtin_enter }, { "list-apps", xdg_app_builtin_list_apps, "List installed applications" },
{ "add-remote", xdg_app_builtin_add_remote }, { "\n Running applications" },
{ "delete-remote", xdg_app_builtin_delete_remote }, { "run", xdg_app_builtin_run, "Run an application" },
{ "modify-remote", xdg_app_builtin_modify_remote }, { "override", xdg_app_builtin_override, "Override permissions for an application" },
{ "ls-remote", xdg_app_builtin_ls_remote }, { "export-file", xdg_app_builtin_export_file, "Grant an application access to a specific file" },
{ "list-remotes", xdg_app_builtin_list_remotes }, { "make-current", xdg_app_builtin_make_current_app, "Specify default version to run" },
{ "list-runtimes", xdg_app_builtin_list_runtimes }, { "enter", xdg_app_builtin_enter, "Enter the namespace of a running application" },
{ "list-apps", xdg_app_builtin_list_apps },
{ "override", xdg_app_builtin_override },
{ "export-file", xdg_app_builtin_export_file },
{ "build-init", xdg_app_builtin_build_init },
{ "build", xdg_app_builtin_build },
{ "build-finish", xdg_app_builtin_build_finish },
{ "build-export", xdg_app_builtin_build_export },
{ "build-bundle", xdg_app_builtin_build_bundle },
{ "repo-update", xdg_app_builtin_repo_update },
/* Deprecated */ { "\n Manage remote repositories" },
{ "install-runtime", xdg_app_builtin_install_runtime, TRUE }, { "remote-add", xdg_app_builtin_add_remote, "Add a new remote repository (by URL)" },
{ "install-app", xdg_app_builtin_install_app, TRUE }, { "remote-modify", xdg_app_builtin_modify_remote, "Modify properties of a configured remote" },
{ "update-app", xdg_app_builtin_update_app, TRUE }, { "remote-delete", xdg_app_builtin_delete_remote, "Delete a configured remote" },
{ "update-runtime", xdg_app_builtin_update_runtime, TRUE }, { "remote-list", xdg_app_builtin_list_remotes, "List all configured remotes" },
{ "uninstall-runtime", xdg_app_builtin_uninstall_runtime }, { "remote-ls", xdg_app_builtin_ls_remote, "List contents of a configured remote" },
{ "uninstall-app", xdg_app_builtin_uninstall_app, TRUE },
{ "install-bundle", xdg_app_builtin_install_bundle, TRUE }, { "\n Build applications" },
{ "make-app-current", xdg_app_builtin_make_current_app, TRUE }, { "build-init", xdg_app_builtin_build_init, "Initialize a directory for building" },
{ "build", xdg_app_builtin_build, "Run a build command inside the build dir" },
{ "build-finish", xdg_app_builtin_build_finish, "Finish a build dir for export" },
{ "build-export", xdg_app_builtin_build_export, "Export a build dir to a repository" },
{ "build-bundle", xdg_app_builtin_build_bundle, "Create a bundle file from a build directory" },
{ "build-update-repo", xdg_app_builtin_build_update_repo, "Update the summary file in a repository" },
/* Deprecated old names */
{ "install-runtime", xdg_app_builtin_install_runtime, NULL, TRUE },
{ "install-app", xdg_app_builtin_install_app, NULL, TRUE },
{ "update-app", xdg_app_builtin_update_app, NULL, TRUE },
{ "update-runtime", xdg_app_builtin_update_runtime, NULL, TRUE },
{ "uninstall-runtime", xdg_app_builtin_uninstall_runtime, NULL, TRUE },
{ "uninstall-app", xdg_app_builtin_uninstall_app, NULL, TRUE },
{ "install-bundle", xdg_app_builtin_install_bundle, NULL, TRUE },
{ "make-app-current", xdg_app_builtin_make_current_app, NULL, TRUE },
{ "add-remote", xdg_app_builtin_add_remote, NULL, TRUE },
{ "delete-remote", xdg_app_builtin_delete_remote, NULL, TRUE },
{ "modify-remote", xdg_app_builtin_modify_remote, NULL, TRUE },
{ "ls-remote", xdg_app_builtin_ls_remote, NULL, TRUE },
{ "list-remotes", xdg_app_builtin_list_remotes, NULL, TRUE },
{ NULL } { NULL }
}; };
@ -115,7 +127,16 @@ xdg_app_option_context_new_with_commands (XdgAppCommand *commands)
while (commands->name != NULL) while (commands->name != NULL)
{ {
if (!commands->deprecated) if (!commands->deprecated)
g_string_append_printf (summary, "\n %s", commands->name); {
if (commands->fn != NULL)
{
g_string_append_printf (summary, "\n %s", commands->name);
if (commands->description)
g_string_append_printf (summary, "%*s%s", (int)(20 - strlen (commands->name)), "", commands->description);
}
else
g_string_append_printf (summary, "\n%s", commands->name);
}
commands++; commands++;
} }
@ -247,7 +268,8 @@ xdg_app_run (int argc,
command = commands; command = commands;
while (command->name) while (command->name)
{ {
if (g_strcmp0 (command_name, command->name) == 0) if (command->fn != NULL &&
g_strcmp0 (command_name, command->name) == 0)
break; break;
command++; command++;
} }