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 <factory.hpp>
10 : #include <listcommands.hpp>
11 :
12 : #include <iostream>
13 :
14 : #include <cmdline.hpp>
15 :
16 : using namespace kdb;
17 : using namespace std;
18 :
19 78 : ListCommandsCommand::ListCommandsCommand ()
20 : {
21 0 : }
22 :
23 0 : int ListCommandsCommand::execute (Cmdline const & cl)
24 : {
25 0 : Factory f;
26 :
27 0 : std::vector<std::string> commands;
28 : try
29 : {
30 0 : if (cl.verbose)
31 : {
32 0 : commands = f.getPrettyCommands ();
33 : }
34 : else
35 : {
36 0 : commands = f.getCommands ();
37 : }
38 : }
39 0 : catch (kdb::KDBException const & ce)
40 : {
41 : std::cerr << "Sorry, I have a severe problem, it seems like I am not installed correctly!\n"
42 0 : << "kdbOpen() failed with the info:" << std::endl
43 0 : << ce.what () << std::endl
44 0 : << "Please report the issue at https://issues.libelektra.org/";
45 : return 8;
46 : }
47 :
48 0 : if (cl.verbose) cout << "number of all commands: " << commands.size () << endl;
49 :
50 0 : for (auto & command : commands)
51 : {
52 0 : std::cout << command;
53 :
54 0 : if (cl.null)
55 : {
56 : cout << '\0';
57 : }
58 : else
59 : {
60 : cout << endl;
61 : }
62 : }
63 :
64 : return 0;
65 : }
66 :
67 78 : ListCommandsCommand::~ListCommandsCommand ()
68 : {
69 7242 : }
|