MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / parse_cli

Function parse_cli

tests/test-backend-sampler.cpp:1034–1091  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1032};
1033
1034static test_args parse_cli(int argc, char ** argv) {
1035 test_args out;
1036
1037 for (int i = 1; i < argc; ++i) {
1038 const char * arg = argv[i];
1039
1040 if (std::strcmp(arg, "--test") == 0) {
1041 if (i + 1 >= argc) {
1042 fprintf(stderr, "--test expects a value\n");
1043 exit(EXIT_FAILURE);
1044 }
1045 out.test = argv[++i];
1046 continue;
1047 }
1048 if (std::strncmp(arg, "--test=", 7) == 0) {
1049 out.test = arg + 7;
1050 continue;
1051 }
1052 if (std::strcmp(arg, "--model") == 0) {
1053 if (i + 1 >= argc) {
1054 fprintf(stderr, "--model expects a value\n");
1055 exit(EXIT_FAILURE);
1056 }
1057 out.model = argv[++i];
1058 continue;
1059 }
1060 if (std::strncmp(arg, "--model=", 8) == 0) {
1061 out.model = arg + 8;
1062 continue;
1063 }
1064 if (std::strcmp(arg, "--device") == 0) {
1065 if (i + 1 >= argc) {
1066 fprintf(stderr, "--device expects a value (cpu or gpu)\n");
1067 exit(EXIT_FAILURE);
1068 }
1069 out.device = argv[++i];
1070 continue;
1071 }
1072 if (std::strncmp(arg, "--device=", 9) == 0) {
1073 out.device = arg + 9;
1074 continue;
1075 }
1076 if (out.model.empty()) {
1077 out.model = arg;
1078 continue;
1079 }
1080
1081 fprintf(stderr, "Unexpected argument: %s\n", arg);
1082 exit(EXIT_FAILURE);
1083 }
1084
1085 if (out.device != "cpu" && out.device != "gpu" && out.device != "auto") {
1086 fprintf(stderr, "Invalid device '%s'. Must be 'cpu', 'gpu' or 'auto'\n", out.device.c_str());
1087 exit(EXIT_FAILURE);
1088 }
1089
1090 return out;
1091}

Callers 1

mainFunction · 0.85

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected