aboutsummaryrefslogtreecommitdiff
path: root/source/apps/src/wandac/cli.cpp
blob: 6be1e18c5d6aed5c4eb0e03b2f41e1de207db03b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "wanda/wandac/cli.hpp"

#include <lyra/arg.hpp>
#include <lyra/help.hpp>

#include <ostream>

namespace wandac
{

  auto cli::parse(lyra::args arguments, std::ostream & error_stream) -> bool
  {
    parser |=  //
        lyra::help(help) |  //
        lyra::arg{command, "command"}("The command to send to the deamon").required();

    auto result = parser.parse(arguments);

    if (!result)
    {
      error_stream << "Error while processing command line arguments: " << result.message() << '\n' << parser << '\n';
      return false;
    }

    return true;
  }

  auto cli::print_usage(std::ostream & output_stream) -> void { output_stream << parser << '\n'; }

}  // namespace wandac