root/cli.hpp @ 31

Revision 31, 1.5 KB (checked in by freek.de.bruijn@…, 2 years ago)

Check whether option 1 or 2 are given before using them in CLI constructor.

Line 
1#include "anyoption.h"
2#include "analyzer.hpp"
3#include "statusoutputcli.hpp"
4#include "progressoutputcli.hpp"
5#include <QObject>
6#include <QString>
7
8#ifndef CLI_HPP
9#define CLI_HPP
10/*
11 * CLI class, for starting pView in CLI modus
12
13 */
14class CLI : public QObject
15{
16Q_OBJECT
17public:
18    // Constructor, set up AnyOption.
19    CLI(int argc, char *argv[]) : ms1profile(false), ms2profile(false){
20
21        opt.addUsage("Usage");
22        opt.addUsage("");
23        opt.addUsage(" -h --help          prints this help");
24        opt.addUsage("");
25        opt.addUsage("All of these have to be provided:");
26        opt.addUsage(" -d --directory     the location of the folder structure");
27        opt.addUsage(" -o --output        output file");
28        opt.addUsage(" -1 --ms1profile    ms1 profile mode (true/false)");
29        opt.addUsage(" -2 --ms2profile    ms2 profile mode (true/false)");
30
31        opt.autoUsagePrint(true);
32
33        opt.setFlag("help", 'h');
34        opt.setOption("output",'o');
35        opt.setOption("directory",'d');
36        opt.setOption("ms1profile", '1');
37        opt.setOption("ms2profile", '2');
38
39        opt.processCommandArgs(argc, argv);
40
41        if ((opt.getValue('1') != NULL) && strcmp(opt.getValue('1'), "true")) ms1profile = true;
42        if ((opt.getValue('2') != NULL) && strcmp(opt.getValue('2'), "true")) ms2profile = true;
43    }
44
45private:
46    AnyOption opt;
47    bool ms1profile, ms2profile;
48
49    int display_help_if_wanted();
50    bool check_parameters_ok();
51
52public slots:
53    int run();
54};
55
56#endif // CLI_HPP
Note: See TracBrowser for help on using the browser.