MCPcopy Create free account
hub / github.com/admtrv/objcurses / parse_args

Function parse_args

main.cpp:160–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158};
159
160static Args parse_args(int argc, char **argv)
161{
162 Args a;
163 for (int i = 1; i < argc; ++i)
164 {
165 const std::string_view arg{argv[i]};
166
167 // help
168 if (arg == "-h" || arg == "--help")
169 {
170 print_help();
171 std::exit(0);
172 }
173
174 // version
175 if (arg == "-v" || arg == "--version")
176 {
177 print_version();
178 std::exit(0);
179 }
180
181 // flags
182 if (arg == "-c" || arg == "--color")
183 {
184 a.color_support = true;
185
186 if (i + 1 < argc && argv[i + 1][0] != '-')
187 {
188 std::string_view next{argv[i + 1]};
189 if (next == "dark")
190 {
191 a.theme = Theme::Dark;
192 ++i;
193 }
194 else if (next == "light")
195 {
196 a.theme = Theme::Light;
197 ++i;
198 }
199 else if (next == "transparent")
200 {
201 a.theme = Theme::Transparent;
202 ++i;
203 }
204 // else next - file name
205 }
206 }
207 else if (arg == "-l" || arg == "--light")
208 {
209 a.static_light = true;
210 }
211 else if (arg == "-a" || arg == "--animate")
212 {
213 a.animate = true;
214
215 if (i + 1 < argc && argv[i + 1][0] != '-')
216 {
217 if (auto val = safe_stof(argv[i + 1]); val)

Callers 1

mainFunction · 0.85

Calls 3

print_helpFunction · 0.85
print_versionFunction · 0.85
safe_stofFunction · 0.85

Tested by

no test coverage detected