MCPcopy Create free account
hub / github.com/MusicPlayerDaemon/MPD / ParseCommandLine

Function ParseCommandLine

test/run_input.cxx:79–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79static CommandLine
80ParseCommandLine(int argc, char **argv)
81{
82 CommandLine c;
83
84 OptionParser option_parser(option_defs, argc, argv);
85 while (auto o = option_parser.Next()) {
86 switch (Option(o.index)) {
87 case OPTION_CONFIG:
88 c.config_path = o.value;
89 break;
90
91 case OPTION_VERBOSE:
92 c.verbose = true;
93 break;
94
95 case OPTION_SCAN:
96 c.scan = true;
97 break;
98
99 case OPTION_SEEK:
100 c.seek = ParseSize(o.value);
101 break;
102
103 case OPTION_CHUNK_SIZE:
104 c.chunk_size = ParseSize(o.value);
105 if (c.chunk_size <= 0 || c.chunk_size > MAX_CHUNK_SIZE)
106 throw std::runtime_error("Invalid chunk size");
107 break;
108 }
109 }
110
111 auto args = option_parser.GetRemaining();
112 if (args.size() != 1)
113 throw std::runtime_error("Usage: run_input [--verbose] [--config=FILE] [--scan] [--chunk-size=BYTES] URI");
114
115 c.uri = args.front();
116 return c;
117}
118
119class GlobalInit {
120 const ConfigData config;

Callers 1

mainFunction · 0.70

Calls 3

NextMethod · 0.80
OptionEnum · 0.70
ParseSizeFunction · 0.70

Tested by

no test coverage detected