forked from Mirrors/flatpak-builder
Merge list-apps and list-runtimes into single list command
parent
37c6485183
commit
025fa4e4d6
|
@ -34,20 +34,53 @@
|
|||
static gboolean opt_show_details;
|
||||
static gboolean opt_user;
|
||||
static gboolean opt_system;
|
||||
static gboolean opt_runtime;
|
||||
static gboolean opt_app;
|
||||
|
||||
static GOptionEntry options[] = {
|
||||
{ "user", 0, 0, G_OPTION_ARG_NONE, &opt_user, "Show user installations", NULL },
|
||||
{ "system", 0, 0, G_OPTION_ARG_NONE, &opt_system, "Show system-wide installations", NULL },
|
||||
{ "show-details", 'd', 0, G_OPTION_ARG_NONE, &opt_show_details, "Show arches and branches", NULL },
|
||||
{ "runtime", 0, 0, G_OPTION_ARG_NONE, &opt_runtime, "List installed runtimes", },
|
||||
{ "app", 0, 0, G_OPTION_ARG_NONE, &opt_app, "List installed applications", },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static char **
|
||||
join_strv (char **a, char **b)
|
||||
{
|
||||
gsize len = 1, i, j;
|
||||
char **res;
|
||||
|
||||
if (a)
|
||||
len += g_strv_length (a);
|
||||
if (b)
|
||||
len += g_strv_length (b);
|
||||
|
||||
res = g_new (char *, len);
|
||||
|
||||
i = 0;
|
||||
|
||||
for (j = 0; a != NULL && a[j] != NULL; j++)
|
||||
res[i++] = g_strdup (a[j]);
|
||||
|
||||
for (j = 0; b != NULL && b[j] != NULL; j++)
|
||||
res[i++] = g_strdup (b[j]);
|
||||
|
||||
res[i++] = NULL;
|
||||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
print_installed_refs (const char *kind, gboolean print_system, gboolean print_user, GCancellable *cancellable, GError **error)
|
||||
print_installed_refs (gboolean app, gboolean runtime, gboolean print_system, gboolean print_user, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autofree char *last = NULL;
|
||||
g_auto(GStrv) system = NULL;
|
||||
g_auto(GStrv) system_app = NULL;
|
||||
g_auto(GStrv) system_runtime = NULL;
|
||||
g_auto(GStrv) user = NULL;
|
||||
g_auto(GStrv) user_app = NULL;
|
||||
g_auto(GStrv) user_runtime = NULL;
|
||||
int s, u;
|
||||
|
||||
if (print_user)
|
||||
|
@ -58,7 +91,9 @@ print_installed_refs (const char *kind, gboolean print_system, gboolean print_us
|
|||
|
||||
if (xdg_app_dir_ensure_repo (dir, cancellable, NULL))
|
||||
{
|
||||
if (!xdg_app_dir_list_refs (dir, kind, &user, cancellable, error))
|
||||
if (app && !xdg_app_dir_list_refs (dir, "app", &user_app, cancellable, error))
|
||||
return FALSE;
|
||||
if (runtime && !xdg_app_dir_list_refs (dir, "runtime", &user_runtime, cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -70,17 +105,17 @@ print_installed_refs (const char *kind, gboolean print_system, gboolean print_us
|
|||
dir = xdg_app_dir_get (FALSE);
|
||||
if (xdg_app_dir_ensure_repo (dir, cancellable, NULL))
|
||||
{
|
||||
if (!xdg_app_dir_list_refs (dir, kind, &system, cancellable, error))
|
||||
if (app && !xdg_app_dir_list_refs (dir, "app", &system_app, cancellable, error))
|
||||
return FALSE;
|
||||
if (runtime && !xdg_app_dir_list_refs (dir, "runtime", &system_runtime, cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
XdgAppTablePrinter *printer = xdg_app_table_printer_new ();
|
||||
|
||||
if (user == NULL)
|
||||
user = g_new0 (char *, 1);
|
||||
if (system == NULL)
|
||||
system = g_new0 (char *, 1);
|
||||
user = join_strv (user_app, user_runtime);
|
||||
system = join_strv (system_app, system_runtime);
|
||||
|
||||
for (s = 0, u = 0; system[s] != NULL || user[u] != NULL; )
|
||||
{
|
||||
|
@ -142,7 +177,7 @@ print_installed_refs (const char *kind, gboolean print_system, gboolean print_us
|
|||
if (print_user && print_system)
|
||||
xdg_app_table_printer_append_with_comma (printer, is_user ? "user" : "system");
|
||||
|
||||
if (strcmp (kind, "app") == 0)
|
||||
if (strcmp (parts[0], "app") == 0)
|
||||
{
|
||||
g_autofree char *current;
|
||||
|
||||
|
@ -150,6 +185,11 @@ print_installed_refs (const char *kind, gboolean print_system, gboolean print_us
|
|||
if (current && strcmp (ref, current) == 0)
|
||||
xdg_app_table_printer_append_with_comma (printer, "current");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (app)
|
||||
xdg_app_table_printer_append_with_comma (printer, "runtime");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -170,16 +210,19 @@ print_installed_refs (const char *kind, gboolean print_system, gboolean print_us
|
|||
}
|
||||
|
||||
gboolean
|
||||
xdg_app_builtin_list_runtimes (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
xdg_app_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
|
||||
context = g_option_context_new (" - List installed runtimes");
|
||||
context = g_option_context_new (" - List installed apps and/or runtimes");
|
||||
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!print_installed_refs ("runtime",
|
||||
if (!opt_app && !opt_runtime)
|
||||
opt_app = TRUE;
|
||||
|
||||
if (!print_installed_refs (opt_app, opt_runtime,
|
||||
opt_system || (!opt_user && !opt_system),
|
||||
opt_user || (!opt_user && !opt_system),
|
||||
cancellable, error))
|
||||
|
@ -188,21 +231,16 @@ xdg_app_builtin_list_runtimes (int argc, char **argv, GCancellable *cancellable,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xdg_app_builtin_list_runtimes (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
opt_runtime = TRUE;
|
||||
return xdg_app_builtin_list (argc, argv, cancellable, error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
xdg_app_builtin_list_apps (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
|
||||
context = g_option_context_new (" - List installed applications");
|
||||
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!print_installed_refs ("app",
|
||||
opt_system || (!opt_user && !opt_system),
|
||||
opt_user || (!opt_user && !opt_system),
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
opt_app = TRUE;
|
||||
return xdg_app_builtin_list (argc, argv, cancellable, error);
|
||||
}
|
||||
|
|
|
@ -55,11 +55,10 @@ BUILTINPROTO(ls_remote);
|
|||
BUILTINPROTO(list_remotes);
|
||||
BUILTINPROTO(install);
|
||||
BUILTINPROTO(update);
|
||||
BUILTINPROTO(list_runtimes);
|
||||
BUILTINPROTO(make_current_app);
|
||||
BUILTINPROTO(uninstall);
|
||||
BUILTINPROTO(install_bundle);
|
||||
BUILTINPROTO(list_apps);
|
||||
BUILTINPROTO(list);
|
||||
BUILTINPROTO(run);
|
||||
BUILTINPROTO(enter);
|
||||
BUILTINPROTO(build_init);
|
||||
|
@ -78,6 +77,8 @@ BUILTINPROTO(update_runtime);
|
|||
BUILTINPROTO(update_app);
|
||||
BUILTINPROTO(uninstall_runtime);
|
||||
BUILTINPROTO(uninstall_app);
|
||||
BUILTINPROTO(list_apps);
|
||||
BUILTINPROTO(list_runtimes);
|
||||
|
||||
#undef BUILTINPROTO
|
||||
|
||||
|
|
|
@ -47,8 +47,7 @@ static XdgAppCommand commands[] = {
|
|||
{ "install", xdg_app_builtin_install, "Install an application or runtime from a remote"},
|
||||
{ "update", xdg_app_builtin_update, "Update an installed application or runtime"},
|
||||
{ "uninstall", xdg_app_builtin_uninstall, "Uninstall an installed application or runtime" },
|
||||
{ "list-runtimes", xdg_app_builtin_list_runtimes, "List installed runtimes" },
|
||||
{ "list-apps", xdg_app_builtin_list_apps, "List installed applications" },
|
||||
{ "list", xdg_app_builtin_list, "List installed apps and/or runtimes" },
|
||||
|
||||
{ "\n Running applications" },
|
||||
{ "run", xdg_app_builtin_run, "Run an application" },
|
||||
|
@ -86,6 +85,8 @@ static XdgAppCommand commands[] = {
|
|||
{ "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 },
|
||||
{ "list-runtimes", xdg_app_builtin_list_runtimes, NULL, TRUE },
|
||||
{ "list-apps", xdg_app_builtin_list_apps, NULL, TRUE },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -27,8 +27,7 @@ man_MANS = \
|
|||
xdg-app-install.1 \
|
||||
xdg-app-update.1 \
|
||||
xdg-app-uninstall.1 \
|
||||
xdg-app-list-runtimes.1 \
|
||||
xdg-app-list-apps.1 \
|
||||
xdg-app-list.1 \
|
||||
xdg-app-make-current.1 \
|
||||
xdg-app-run.1 \
|
||||
xdg-app-override.1 \
|
||||
|
|
|
@ -1,138 +0,0 @@
|
|||
<?xml version='1.0'?> <!--*-nxml-*-->
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
||||
|
||||
<refentry id="xdg-app-list-runtimes">
|
||||
|
||||
<refentryinfo>
|
||||
<title>xdg-app list-runtimes</title>
|
||||
<productname>xdg-app</productname>
|
||||
|
||||
<authorgroup>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Alexander</firstname>
|
||||
<surname>Larsson</surname>
|
||||
<email>alexl@redhat.com</email>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>xdg-app list-runtimes</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>xdg-app-list-runtimes</refname>
|
||||
<refpurpose>List installed runtimes</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>xdg-app list-runtimes</command>
|
||||
<arg choice="opt" rep="repeat">OPTION</arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
Lists the names of the installed runtimes.
|
||||
</para>
|
||||
<para>
|
||||
By default, both per-user and system-wide installations are shown.
|
||||
Use the --user or --system options to change this.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Options</title>
|
||||
|
||||
<para>The following options are understood:</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><option>-h</option></term>
|
||||
<term><option>--help</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Show help options and exit.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--user</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Show per-user installations.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--system</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Show system-wide installations.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--show-details</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Show arches and branches, in addition to the runtime names.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-v</option></term>
|
||||
<term><option>--verbose</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Print debug information during command processing.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--version</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Print version information and exit.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Examples</title>
|
||||
|
||||
<para>
|
||||
<command>$ xdg-app --user list-runtimes --show-details</command>
|
||||
</para>
|
||||
<programlisting>
|
||||
org.gnome.Platform.Var/x86_64/3.16
|
||||
org.gnome.Sdk.Var/x86_64/3.16
|
||||
org.gnome.Sdk/x86_64/3.14
|
||||
org.gnome.Sdk/x86_64/3.16
|
||||
org.gnome.Platform/x86_64/3.16
|
||||
org.gnome.Platform/x86_64/3.14
|
||||
</programlisting>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>See also</title>
|
||||
|
||||
<para>
|
||||
<citerefentry><refentrytitle>xdg-app</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>xdg-app-install-runtime</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>xdg-app-update-runtime</refentrytitle><manvolnum>1</manvolnum></citerefentry>
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
|
@ -2,10 +2,10 @@
|
|||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
||||
|
||||
<refentry id="xdg-app-list-apps">
|
||||
<refentry id="xdg-app-list">
|
||||
|
||||
<refentryinfo>
|
||||
<title>xdg-app list-apps</title>
|
||||
<title>xdg-app list</title>
|
||||
<productname>xdg-app</productname>
|
||||
|
||||
<authorgroup>
|
||||
|
@ -19,18 +19,18 @@
|
|||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>xdg-app list-apps</refentrytitle>
|
||||
<refentrytitle>xdg-app list</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>xdg-app-list-apps</refname>
|
||||
<refpurpose>List installed applications</refpurpose>
|
||||
<refname>xdg-app-list</refname>
|
||||
<refpurpose>List installed applications and/or runtimes</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>xdg-app list-apps</command>
|
||||
<command>xdg-app list</command>
|
||||
<arg choice="opt" rep="repeat">OPTION</arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
@ -39,13 +39,17 @@
|
|||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
Lists the names of the installed applications.
|
||||
Lists the names of the installed applications and/or runtime.
|
||||
</para>
|
||||
<para>
|
||||
By default, both per-user and system-wide installations
|
||||
are shown. Use the --user or --system options to change
|
||||
this.
|
||||
</para>
|
||||
<para>
|
||||
By default this lists the installed apps, but you can
|
||||
change this by using the --app or --runtime option.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
|
@ -88,6 +92,21 @@
|
|||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--app</option></term>
|
||||
|
||||
<listitem><para>
|
||||
List applications.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--runtime</option></term>
|
||||
|
||||
<listitem><para>
|
||||
List runtimes.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>-v</option></term>
|
||||
<term><option>--verbose</option></term>
|
||||
|
@ -111,7 +130,7 @@
|
|||
<title>Examples</title>
|
||||
|
||||
<para>
|
||||
<command>$ xdg-app --user list-apps</command>
|
||||
<command>$ xdg-app --user list</command>
|
||||
</para>
|
||||
<programlisting>
|
||||
org.gnome.Builder
|
Loading…
Reference in New Issue