1 #ifndef DBALLE_CMDLINE_CMDLINE_H
2 #define DBALLE_CMDLINE_CMDLINE_H
10 #include <dballe/file.h>
29 std::vector<std::string> names;
37 virtual void add_to_optable(std::vector<poptOption>& opts)
const;
42 virtual int main(poptContext) = 0;
52 poptContext
make_popt_context(
int argc,
const char* argv[], std::vector<poptOption>& opts)
const;
53 void manpage_print_options(FILE* out);
56 #define ODT_END { NULL, NULL, NULL, NULL, NULL, NULL }
63 std::string manpage_examples_section;
64 std::string manpage_files_section;
65 std::string manpage_seealso_section;
67 std::vector<Subcommand*> ops;
75 Subcommand* find_action(
const std::string& name)
const;
77 void usage(
const std::string& selfpath, FILE* out)
const;
78 void manpage(FILE* out)
const;
81 int main(
int argc,
const char* argv[]);
93 virtual const char* what()
const throw () {
return msg.c_str(); }
96 static void throwf(
const char* fmt, ...) WREPORT_THROWF_ATTRS(1, 2);
103 void dba_cmdline_print_dba_error();
109 void dba_cmdline_error(poptContext optCon, const
char* fmt, ...) __attribute__ ((noreturn));
114 File::Encoding string_to_encoding(const
char* type);
121 unsigned dba_cmdline_get_query(poptContext optCon, Query& query);
126 void list_templates();
129 std::list<std::
string> get_filenames(poptContext optCon);
error_cmdline(const std::string &msg)
Definition: cmdline.h:90
Key/value store where keys are strings and values are wreport variables.
Definition: record.h:17
static void throwf(const char *fmt,...) WREPORT_THROWF_ATTRS(1
Throw the exception, building the message printf-style.
poptContext make_popt_context(int argc, const char *argv[], std::vector< poptOption > &opts) const
Create a popt context for this subcommand.
void add_subcommand(Subcommand *action)
Add an action to this tool, taking ownership of its memory management.
virtual void init()
Optional initialization before main is called.
Query used to filter DB-All.e data.
Definition: query.h:14
std::string msg
error message returned by what()
Definition: cmdline.h:87
Report an error with command line options.
Definition: cmdline.h:85
int main(int argc, const char *argv[])
Process commandline arguments and perform the action requested.