LCOV - code coverage report
Current view: top level - src/tools/kdb - metaremove.cpp (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 5 18 27.8 %
Date: 2019-09-12 12:28:41 Functions: 3 5 60.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 <metaremove.hpp>
      10             : 
      11             : #include <cmdline.hpp>
      12             : #include <kdb.hpp>
      13             : 
      14             : #include <iostream>
      15             : #include <string>
      16             : 
      17             : using namespace std;
      18             : using namespace kdb;
      19             : 
      20          78 : MetaRemoveCommand::MetaRemoveCommand ()
      21             : {
      22          78 : }
      23             : 
      24         156 : MetaRemoveCommand::~MetaRemoveCommand ()
      25             : {
      26          78 : }
      27             : 
      28           0 : int MetaRemoveCommand::execute (Cmdline const & cl)
      29             : {
      30           0 :         if (cl.arguments.size () != 2)
      31             :         {
      32           0 :                 throw invalid_argument ("Need 2 arguments");
      33             :         }
      34           0 :         Key parentKey = cl.createKey (0);
      35           0 :         string metaname = cl.arguments[1];
      36             : 
      37           0 :         KeySet conf;
      38           0 :         kdb.get (conf, parentKey);
      39           0 :         printWarnings (cerr, parentKey, cl.verbose, cl.debug);
      40             : 
      41           0 :         Key k = conf.lookup (parentKey);
      42             : 
      43           0 :         if (!k)
      44             :         {
      45           0 :                 cerr << "Key not found" << endl;
      46             :                 return 1;
      47             :         }
      48             : 
      49           0 :         k.delMeta (metaname);
      50             : 
      51           0 :         kdb.set (conf, parentKey);
      52             : 
      53             :         return 0;
      54        7164 : }

Generated by: LCOV version 1.13