MCPcopy Create free account
hub / github.com/BabitMF/bmf / main

Function main

bmf/cmd/src/module_manager.cpp:222–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220}
221
222int main(int argc, char **argv) {
223 if (argc < 2) {
224 help(argv[0], nullptr);
225 exit(EXIT_FAILURE);
226 }
227
228 if (char *log_level = getenv("BMF_LOG_LEVEL"); log_level) {
229 char buf[256];
230 sprintf(buf, "BMF_LOG_LEVEL=%s", log_level);
231 putenv(buf);
232 } else {
233 putenv("BMF_LOG_LEVEL=WARNING");
234 }
235 configure_bmf_log();
236
237 const std::string operation = argv[1];
238 if (operation == "help") {
239 const char *cmd = argc >= 3 ? argv[2] : nullptr;
240 help(argv[0], cmd);
241 return 0;
242 } else if (operation == "list") {
243 int ret = list_modules();
244 if (ret < 0) {
245 BMFLOG(BMF_ERROR) << "list modules failed." << std::endl;
246 exit(EXIT_FAILURE);
247 }
248 } else if (operation == "dump") {
249 if (argc < 3) {
250 help(argv[0], operation.c_str());
251 exit(EXIT_FAILURE);
252 }
253 const char *module_name = argv[2];
254 int ret = dump_module(module_name);
255 if (ret < 0) {
256 BMFLOG(BMF_ERROR) << "dump module info failed." << std::endl;
257 exit(EXIT_FAILURE);
258 }
259 } else if (operation == "install") {
260 bool force = false;
261 int arg_start = 2;
262 if (argc < arg_start + 1) {
263 help(argv[0], operation.c_str());
264 exit(EXIT_FAILURE);
265 }
266
267 if (std::string(argv[arg_start]) == "-f") {
268 force = true;
269 arg_start++;
270 }
271
272 if (argc < arg_start + 4) {
273 help(argv[0], operation.c_str());
274 exit(EXIT_FAILURE);
275 }
276
277 const char *module_revision = "v0.0.1";
278 if (argc >= arg_start + 5) {
279 module_revision = argv[arg_start + 4];

Callers

nothing calls this directly

Calls 6

helpFunction · 0.85
configure_bmf_logFunction · 0.85
list_modulesFunction · 0.85
dump_moduleFunction · 0.85
install_moduleFunction · 0.85
uninstall_moduleFunction · 0.85

Tested by

no test coverage detected