LCOV - code coverage report
Current view: top level - main/src - CommandLine.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 27 0.0 %
Date: 2025-01-05 01:19:03 Functions: 0 1 0.0 %

          Line data    Source code
       1             : //----------------------------------------------------------------
       2             : //
       3             : // File: CommandLine.cpp
       4             : //
       5             : //----------------------------------------------------------------
       6             : 
       7             : #include "CommandLine.h"
       8             : #include <iostream>
       9             : #include <string>
      10             : #include <cxxopts.hpp>
      11             : #include <rang.hpp>
      12             : #include "gen/BuildInfo.h"
      13             : 
      14             : using namespace App;
      15             : 
      16             : /*-----------------------------------------------------------*//**
      17             : 
      18             : Constructor
      19             : 
      20             : @param[in] argc
      21             :     Number of items in argv array.
      22             : 
      23             : @param[in] argv
      24             :     Array of command line args.
      25             : 
      26             : @param[in] bld
      27             :     Build info
      28             : */
      29           0 : CommandLine::CommandLine(int argc, char* argv[],
      30             :                          const Gen::BuildInfo& bld)
      31             : {
      32           0 :     cxxopts::Options options("C++Bootstrap", "A brief description");
      33             : 
      34           0 :     options.add_options()
      35           0 :         ("f,foo", "Param foo",
      36           0 :          cxxopts::value<int>()->default_value("10"))
      37             :         
      38           0 :         ("b,bar", "Param bar",
      39           0 :          cxxopts::value<std::string>())
      40             :         
      41           0 :         ("d,debug", "Enable debugging",
      42           0 :          cxxopts::value<bool>()->default_value("false"))
      43             :         
      44           0 :         ("v,version", "Print version info then exit")
      45             :         
      46           0 :         ("h,help", "Print usage")
      47             :     ;
      48             : 
      49           0 :     auto result = options.parse(argc, argv);
      50             : 
      51           0 :     if (result.count("help"))
      52             :     {
      53           0 :         std::cout << options.help() << std::endl;
      54           0 :         exit(0);
      55             :     }
      56           0 :     if (result.count("version"))
      57             :     {
      58           0 :         std::cout << rang::style::bold
      59           0 :             << bld.shortInfo() << rang::style::reset;
      60           0 :         exit(0);
      61             :     }
      62           0 :     bool debug = result["debug"].as<bool>();
      63           0 :     (void)debug;
      64             :     
      65           0 :     int foo = result["foo"].as<int>();    
      66           0 :     (void)foo;
      67             :     
      68           0 :     std::string bar;
      69           0 :     if (result.count("bar"))
      70           0 :         bar = result["bar"].as<std::string>();
      71           0 : }
      72             : 
      73             : //----------------------------------------------------------------

Generated by: LCOV version 1.16