LCOV - code coverage report
Current view: top level - src/tools/kdb - metals.cpp (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 18 21 85.7 %
Date: 2019-09-12 12:28:41 Functions: 5 5 100.0 %

          Line data    Source code
       1             : /**
       2             :  * @file
       3             :  *
       4             :  * @brief
       5             :  *
       6             :  * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
       7             :  */
       8             : 
       9             : #include <metals.hpp>
      10             : 
      11             : #include <iostream>
      12             : 
      13             : #include <cmdline.hpp>
      14             : #include <kdb.hpp>
      15             : 
      16             : using namespace kdb;
      17             : using namespace std;
      18             : 
      19         188 : MetaLsCommand::MetaLsCommand ()
      20             : {
      21          94 : }
      22             : 
      23          16 : int MetaLsCommand::execute (Cmdline const & cl)
      24             : {
      25          16 :         int ret = 0;
      26          32 :         if (cl.arguments.size () != 1)
      27             :         {
      28           0 :                 throw invalid_argument ("1 argument required");
      29             :         }
      30             : 
      31          32 :         Key root = cl.createKey (0);
      32             : 
      33          16 :         kdb.get (ks, root);
      34             : 
      35          48 :         Key k = ks.lookup (root);
      36             : 
      37          16 :         if (k)
      38             :         {
      39          15 :                 if (cl.verbose)
      40             :                 {
      41           0 :                         std::cout << "Got key " << k.getName () << std::endl;
      42             :                 }
      43             : 
      44             :                 k.rewindMeta ();
      45         168 :                 while (const Key meta = k.nextMeta ())
      46             :                 {
      47         138 :                         cout << meta.getName ();
      48          46 :                         if (cl.null)
      49             :                         {
      50           0 :                                 cout << '\0' << std::flush;
      51             :                         }
      52             :                         else
      53             :                         {
      54             :                                 cout << endl;
      55             :                         }
      56             :                 }
      57             :         }
      58             :         else
      59             :         {
      60           1 :                 std::cerr << "Did not find key" << std::endl;
      61             :                 ret = 1;
      62             :         }
      63             : 
      64          16 :         printWarnings (cerr, root, cl.verbose, cl.debug);
      65             : 
      66          32 :         return ret;
      67             : }
      68             : 
      69         376 : MetaLsCommand::~MetaLsCommand ()
      70             : {
      71        7352 : }

Generated by: LCOV version 1.13