/*-1* Copyright (c) 2012 Marin Atanasov Nikolov <[email protected]>2* Copyright (c) 2014 Matthew Seaman <[email protected]>3* All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer10* in this position and unchanged.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR16* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES17* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.18* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,19* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT20* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,21* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY22* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF24* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.25*/2627#include <getopt.h>28#include <stdio.h>29#include <stdbool.h>30#include <unistd.h>3132#include <pkg.h>3334#include "pkgcli.h"3536void37usage_plugins(void)38{39fprintf(stderr, "Usage: pkg plugins [-l] <plugin>\n\n");40//fprintf(stderr, "For more information see 'pkg help plugins'.\n");41}4243int44exec_plugins(int argc, char **argv)45{46struct pkg_plugin *p = NULL;47int ch;48bool __unused list_only = true;4950struct option longopts[] = {51{ "list-only", no_argument, NULL, 'l' },52{ NULL, 0, NULL, 0 },53};5455while ((ch = getopt_long(argc, argv, "+l", longopts, NULL)) != -1) {56switch (ch) {57case 'l':58list_only = true;59break;60default:61usage_plugins();62return (EXIT_FAILURE);63}64}6566/**67* For now only display the available plugins68* @todo: implement enabling, disabling and configuring of plugins69*/7071printf("%-10s %-45s %-10s\n", "NAME", "DESC", "VERSION");72while (pkg_plugins(&p) != EPKG_END)73printf("%-10s %-45s %-10s\n",74pkg_plugin_get(p, PKG_PLUGIN_NAME),75pkg_plugin_get(p, PKG_PLUGIN_DESC),76pkg_plugin_get(p, PKG_PLUGIN_VERSION));7778return (EXIT_SUCCESS);79}808182