LCOV - code coverage report
Current view: top level - src - plugins.c (source / functions) Hit Total Coverage
Test: cov.info Lines: 0 19 0.0 %
Date: 2015-08-15 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /*-
       2             :  * Copyright (c) 2012 Marin Atanasov Nikolov <dnaeon@gmail.com>
       3             :  * Copyright (c) 2014 Matthew Seaman <matthew@FreeBSD.org>
       4             :  * All rights reserved.
       5             :  * 
       6             :  * Redistribution and use in source and binary forms, with or without
       7             :  * modification, are permitted provided that the following conditions
       8             :  * are met:
       9             :  * 1. Redistributions of source code must retain the above copyright
      10             :  *    notice, this list of conditions and the following disclaimer
      11             :  *    in this position and unchanged.
      12             :  * 2. Redistributions in binary form must reproduce the above copyright
      13             :  *    notice, this list of conditions and the following disclaimer in the
      14             :  *    documentation and/or other materials provided with the distribution.
      15             :  * 
      16             :  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
      17             :  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
      18             :  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
      19             :  * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
      20             :  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
      21             :  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
      22             :  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      23             :  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      24             :  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
      25             :  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      26             :  */
      27             : 
      28             : #include <getopt.h>
      29             : #include <stdio.h>
      30             : #include <stdbool.h>
      31             : #include <sysexits.h>
      32             : #include <unistd.h>
      33             : 
      34             : #include <pkg.h>
      35             : 
      36             : #include "pkgcli.h"
      37             : 
      38             : void
      39           0 : usage_plugins(void)
      40             : {
      41           0 :         fprintf(stderr, "Usage: pkg plugins [-l] <plugin>\n\n");
      42             :         //fprintf(stderr, "For more information see 'pkg help plugins'.\n");
      43           0 : }
      44             : 
      45             : int
      46           0 : exec_plugins(int argc, char **argv)
      47             : {
      48           0 :         struct pkg_plugin *p = NULL;
      49             :         int ch;
      50           0 :         bool __unused list_only = true;
      51             : 
      52           0 :         struct option longopts[] = {
      53             :                 { "list-only",        no_argument,    NULL,   'l' },
      54             :                 { NULL,         0,              NULL,   0   },
      55             :         };
      56             : 
      57           0 :         while ((ch = getopt_long(argc, argv, "+l", longopts, NULL)) != -1) {
      58           0 :                 switch (ch) {
      59             :                 case 'l':
      60           0 :                         list_only = true;
      61           0 :                         break;
      62             :                 default:
      63           0 :                         usage_plugins();
      64           0 :                         return (EX_USAGE);
      65             :                 }
      66             :         }
      67           0 :         argc -= optind;
      68           0 :         argv += optind;
      69             : 
      70             :         /**
      71             :          * For now only display the available plugins
      72             :          * @todo: implement enabling, disabling and configuring of plugins
      73             :          */
      74             : 
      75           0 :         printf("%-10s %-45s %-10s\n", "NAME", "DESC", "VERSION");
      76           0 :         while (pkg_plugins(&p) != EPKG_END)
      77           0 :                 printf("%-10s %-45s %-10s\n",
      78             :                        pkg_plugin_get(p, PKG_PLUGIN_NAME),
      79             :                        pkg_plugin_get(p, PKG_PLUGIN_DESC),
      80             :                        pkg_plugin_get(p, PKG_PLUGIN_VERSION));
      81             : 
      82           0 :         return (EX_OK);
      83             : }

Generated by: LCOV version 1.10