flatpak-builder/xdg-app-builtins-delete-rem...

68 lines
1.8 KiB
C

/*
* Copyright © 2014 Red Hat, Inc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors:
* Alexander Larsson <alexl@redhat.com>
*/
#include "config.h"
#include <locale.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-builtins.h"
gboolean
xdg_app_builtin_delete_remote (int argc, char **argv, GCancellable *cancellable, GError **error)
{
GOptionContext *context;
gboolean ret = FALSE;
g_autoptr(XdgAppDir) dir = NULL;
const char *remote_name;
context = g_option_context_new ("NAME - Delete a remote repository");
if (!xdg_app_option_context_parse (context, NULL, &argc, &argv, 0, &dir, cancellable, error))
goto out;
if (argc < 2)
{
usage_error (context, "NAME must be specified", error);
goto out;
}
remote_name = argv[1];
if (!ostree_repo_remote_change (xdg_app_dir_get_repo (dir), NULL,
OSTREE_REPO_REMOTE_CHANGE_DELETE,
remote_name, NULL,
NULL,
cancellable, error))
goto out;
ret = TRUE;
out:
if (context)
g_option_context_free (context);
return ret;
}