MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / cliFindAssetArgument

Function cliFindAssetArgument

Source/Basic/Application.cpp:156–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154};
155
156CliAssetArgument cliFindAssetArgument(int argc, char* argv[]) {
157 constexpr std::string_view assetPrefix = "--asset=";
158 for (int i = 1; i < argc; i++) {
159 if (!argv[i]) continue;
160 std::string_view arg(argv[i]);
161 if (arg == "--asset") {
162 if (i + 1 >= argc || !argv[i + 1] || !*argv[i + 1]) {
163 return {std::nullopt, "--asset expects a value"};
164 }
165 return {cliAbsolutePath(argv[i + 1]), {}};
166 }
167 if (arg.rfind(assetPrefix, 0) == 0) {
168 auto value = arg.substr(assetPrefix.size());
169 if (value.empty()) {
170 return {std::nullopt, "--asset expects a value"};
171 }
172 return {cliAbsolutePath(std::string(value)), {}};
173 }
174 }
175 return {};
176}
177
178bool cliIsAssetArgument(int argc, char* argv[], int& index) {
179 if (!argv[index]) return false;

Callers 1

runCliApplicationFunction · 0.85

Calls 5

cliAbsolutePathFunction · 0.85
stringFunction · 0.85
substrMethod · 0.65
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected