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 : #ifndef CMDLINE_HPP
10 : #define CMDLINE_HPP
11 :
12 : /* Cmdline parser.
13 : *
14 : * To add an option there are 5 steps.
15 : * Beware not to introduce options which already have
16 : * an meaning in one of the utilities.
17 : * Please always append the options in alphabetical order
18 : * with capitals later.
19 : */
20 :
21 :
22 : #include <map>
23 : #include <string>
24 : #include <vector>
25 :
26 : #include "coloredkdbio.hpp"
27 :
28 : class Command;
29 :
30 : namespace kdb
31 : {
32 : class Key;
33 : class KeySet;
34 : } // namespace kdb
35 :
36 : class Cmdline
37 : {
38 : public:
39 : Cmdline (int argc, char ** argv, Command * command);
40 3580 : ~Cmdline ()
41 60860 : {
42 3580 : }
43 :
44 : /** The synopsis of the command
45 : * Currently it is only printed out.
46 : * May be used to determine number of
47 : * commands in the future.
48 : */
49 : std::string synopsis;
50 :
51 : /** The help text to printed out. */
52 : std::string helpText;
53 :
54 : /** At least one of the options was invalid */
55 : bool invalidOpt;
56 :
57 : /*XXX: Step 1: add your option here.
58 : * (please sort by getopt short name, small letters first)*/
59 : bool debug; /*!< To debug the commands. */
60 : bool force; /*!< Force the action. */
61 : bool load; /*!< Load plugins instead of using system/elektra. */
62 : bool humanReadable; /*!< Human readable values are preferred. */
63 : bool help; /*!< Display help instead of the normal action.. */
64 : bool interactive; /*!< Interactive mode. */
65 : int minDepth; /*!< minimum depth for completion suggestions */
66 : int maxDepth; /*!< maximum depth for completion suggestions */
67 : bool noNewline; /*!< Do not output a newline at the end. */
68 : bool test; /*!< Run some self tests instead of the normal action. */
69 : bool recursive; /*!< Recursive mode. */
70 : std::string resolver;
71 : std::string strategy; /*!< A comma separated list of the used merging strategies. Their order is relevant. */
72 : bool verbose; /*!< Be more verbose: explain what is happening */
73 : bool quiet; /*!< Be quiet: suppress non-error messages */
74 : bool version; /*!< Return version info instead of the normal action.. */
75 : bool withoutElektra;
76 : std::string inputFile;
77 : bool null;
78 : bool first;
79 : bool second;
80 : bool third;
81 : bool withRecommends;
82 : bool all; /*!< Consider all keys for lookup */
83 : std::string format;
84 : std::string plugins;
85 : std::string globalPlugins;
86 : std::string pluginsConfig;
87 : std::string color; /*!< colormode "never", "always" and "auto" to print color if output channel is a tty */
88 : std::string ns;
89 : std::string editor;
90 :
91 : typedef std::map<std::string, std::string> map;
92 : map bookmarks;
93 : std::string profile;
94 :
95 : kdb::Key createKey (int pos, bool allowCascading = true) const;
96 : kdb::Key resolveBookmark (std::string name) const;
97 :
98 : kdb::KeySet getPluginsConfig (std::string basepath = "user/") const;
99 :
100 : /** The path to the kdb exectuable. */
101 : std::string executable;
102 :
103 : /** The given name for the current command.
104 : * This is the second parameter. */
105 : std::string commandName;
106 :
107 : /** The arguments given on the commandline. */
108 : std::vector<std::string> arguments;
109 : };
110 :
111 : std::ostream & operator<< (std::ostream & os, Cmdline & cl);
112 :
113 : #endif
|