-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoptions.cpp
More file actions
66 lines (54 loc) · 1.38 KB
/
Copy pathoptions.cpp
File metadata and controls
66 lines (54 loc) · 1.38 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include "program_options.h"
#include "options.h"
#include "util.h"
using namespace std;
void help(primo::program_options::OptionsConfig<char>& optcfg)
{
cout << "Usage: read_metadata_any_file -i <avfile>\n";
primo::program_options::doHelp(cout, optcfg);
}
void setDefaultOptions(Options& opt)
{
opt.avfile = getExeDir() + "/../assets/aud/Hydrate-Kenny_Beltrey.ogg";
}
bool validateOptions(Options& opt)
{
return (!opt.avfile.empty());
}
ErrorCodes prepareOptions(Options &opt, int argc, char* argv[])
{
if (argc < 2)
{
setDefaultOptions(opt);
cout << "Using defaults:\n";
cout << " --input " << opt.avfile;
cout << endl;
return Parsed;
}
primo::program_options::OptionsConfig<char> optcfg;
optcfg.addOptions()
("help,h", opt.help, "")
("input,i", opt.avfile, string(), "file; if no input is specified a default input file is used.");
try
{
primo::program_options::scanArgv(optcfg, argc, argv);
}
catch (primo::program_options::ParseFailure<char> &ex)
{
cout << ex.message() << endl;
help(optcfg);
return Error;
}
if (opt.help)
{
help(optcfg);
return Command;
}
if (!validateOptions(opt))
{
help(optcfg);
return Error;
}
return Parsed;
}