|
rpm-build |
0fba15 |
/*
|
|
rpm-build |
0fba15 |
* Copyright (C) 2015 Red Hat, Inc.
|
|
rpm-build |
0fba15 |
*
|
|
rpm-build |
0fba15 |
* SPDX-License-Identifier: LGPL-2.0+
|
|
rpm-build |
0fba15 |
*
|
|
rpm-build |
0fba15 |
* This library is free software; you can redistribute it and/or
|
|
rpm-build |
0fba15 |
* modify it under the terms of the GNU Lesser General Public
|
|
rpm-build |
0fba15 |
* License as published by the Free Software Foundation; either
|
|
rpm-build |
0fba15 |
* version 2 of the License, or (at your option) any later version.
|
|
rpm-build |
0fba15 |
*
|
|
rpm-build |
0fba15 |
* This library is distributed in the hope that it will be useful,
|
|
rpm-build |
0fba15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
rpm-build |
0fba15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
rpm-build |
0fba15 |
* Lesser General Public License for more details.
|
|
rpm-build |
0fba15 |
*
|
|
rpm-build |
0fba15 |
* You should have received a copy of the GNU Lesser General Public
|
|
rpm-build |
0fba15 |
* License along with this library; if not, write to the
|
|
rpm-build |
0fba15 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
rpm-build |
0fba15 |
* Boston, MA 02111-1307, USA.
|
|
rpm-build |
0fba15 |
*/
|
|
rpm-build |
0fba15 |
|
|
rpm-build |
0fba15 |
#include "config.h"
|
|
rpm-build |
0fba15 |
|
|
rpm-build |
0fba15 |
#include "ot-main.h"
|
|
rpm-build |
0fba15 |
#include "ot-remote-builtins.h"
|
|
rpm-build |
0fba15 |
|
|
rpm-build |
0fba15 |
static gboolean opt_show_urls;
|
|
rpm-build |
0fba15 |
|
|
rpm-build |
0fba15 |
/* ATTENTION:
|
|
rpm-build |
0fba15 |
* Please remember to update the bash-completion script (bash/ostree) and
|
|
rpm-build |
0fba15 |
* man page (man/ostree-remote.xml) when changing the option list.
|
|
rpm-build |
0fba15 |
*/
|
|
rpm-build |
0fba15 |
|
|
rpm-build |
0fba15 |
static GOptionEntry option_entries[] = {
|
|
rpm-build |
0fba15 |
{ "show-urls", 'u', 0, G_OPTION_ARG_NONE, &opt_show_urls, "Show remote URLs in list", NULL },
|
|
rpm-build |
0fba15 |
{ NULL }
|
|
rpm-build |
0fba15 |
};
|
|
rpm-build |
0fba15 |
|
|
rpm-build |
0fba15 |
gboolean
|
|
rpm-build |
0fba15 |
ot_remote_builtin_list (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
|
rpm-build |
0fba15 |
{
|
|
rpm-build |
0fba15 |
g_autoptr(GOptionContext) context = NULL;
|
|
rpm-build |
0fba15 |
g_autoptr(OstreeRepo) repo = NULL;
|
|
rpm-build |
0fba15 |
g_auto(GStrv) remotes = NULL;
|
|
rpm-build |
0fba15 |
guint ii, n_remotes = 0;
|
|
rpm-build |
0fba15 |
gboolean ret = FALSE;
|
|
rpm-build |
0fba15 |
|
|
rpm-build |
0fba15 |
context = g_option_context_new ("");
|
|
rpm-build |
0fba15 |
|
|
rpm-build |
0fba15 |
if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
|
|
rpm-build |
0fba15 |
invocation, &repo, cancellable, error))
|
|
rpm-build |
0fba15 |
goto out;
|
|
rpm-build |
0fba15 |
|
|
rpm-build |
0fba15 |
remotes = ostree_repo_remote_list (repo, &n_remotes);
|
|
rpm-build |
0fba15 |
|
|
rpm-build |
0fba15 |
if (opt_show_urls)
|
|
rpm-build |
0fba15 |
{
|
|
rpm-build |
0fba15 |
int max_length = 0;
|
|
rpm-build |
0fba15 |
|
|
rpm-build |
0fba15 |
for (ii = 0; ii < n_remotes; ii++)
|
|
rpm-build |
0fba15 |
max_length = MAX (max_length, strlen (remotes[ii]));
|
|
rpm-build |
0fba15 |
|
|
rpm-build |
0fba15 |
for (ii = 0; ii < n_remotes; ii++)
|
|
rpm-build |
0fba15 |
{
|
|
rpm-build |
0fba15 |
g_autofree char *remote_url = NULL;
|
|
rpm-build |
0fba15 |
|
|
rpm-build |
0fba15 |
if (!ostree_repo_remote_get_url (repo, remotes[ii], &remote_url, error))
|
|
rpm-build |
0fba15 |
goto out;
|
|
rpm-build |
0fba15 |
|
|
rpm-build |
0fba15 |
g_print ("%-*s %s\n", max_length, remotes[ii], remote_url);
|
|
rpm-build |
0fba15 |
}
|
|
rpm-build |
0fba15 |
}
|
|
rpm-build |
0fba15 |
else
|
|
rpm-build |
0fba15 |
{
|
|
rpm-build |
0fba15 |
for (ii = 0; ii < n_remotes; ii++)
|
|
rpm-build |
0fba15 |
g_print ("%s\n", remotes[ii]);
|
|
rpm-build |
0fba15 |
}
|
|
rpm-build |
0fba15 |
|
|
rpm-build |
0fba15 |
ret = TRUE;
|
|
rpm-build |
0fba15 |
|
|
rpm-build |
0fba15 |
out:
|
|
rpm-build |
0fba15 |
return ret;
|
|
rpm-build |
0fba15 |
}
|