File: argument_parser_3.cpp

package info (click to toggle)
seqan3 3.0.2%2Bds-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 16,052 kB
  • sloc: cpp: 144,641; makefile: 1,288; ansic: 294; sh: 228; xml: 217; javascript: 50; python: 27; php: 25
file content (39 lines) | stat: -rw-r--r-- 1,233 bytes parent folder | download | duplicates (2)
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
31
32
33
34
35
36
37
38
39
#include <seqan3/argument_parser/all.hpp>

int main(int argc, char ** argv)
{
    seqan3::argument_parser myparser{"Penguin_Parade", argc, argv}; // initialize

    myparser.info.version = "2.0.0";
    myparser.info.date = "12.01.2017";
    myparser.info.short_description = "Organize your penguin parade";
    myparser.info.description.push_back("First Paragraph.");
    myparser.info.description.push_back("Second Paragraph.");
    myparser.info.examples.push_back("./penguin_parade Skipper Kowalski Rico Private -d 10 -m 02 -y 2017");

    int d{01};   // day
    int m{01};   // month
    int y{2050}; // year

    myparser.add_option(d, 'd', "day", "Please specify your preferred day.");
    myparser.add_option(m, 'm', "month", "Please specify your preferred month.");
    myparser.add_option(y, 'y', "year", "Please specify your preferred year.");

    std::vector<std::string> penguin_names;

    myparser.add_positional_option(penguin_names, "Specify the names of the penguins.");

    try
    {
        myparser.parse();
    }
    catch (seqan3::argument_parser_error const & ext) // the user did something wrong
    {
        std::cerr << ext.what() << "\n";
        return -1;
    }

    // organize ...

    return 0;
}