diff --git a/src/bees.cc b/src/bees.cc index 5367de8..c51b897 100644 --- a/src/bees.cc +++ b/src/bees.cc @@ -32,7 +32,7 @@ using namespace std; int bees_log_level = 8; -int +void do_cmd_help(char *argv[]) { // 80col 01234567890123456789012345678901234567890123456789012345678901234567890123456789 @@ -73,7 +73,6 @@ do_cmd_help(char *argv[]) "\n" // 80col 01234567890123456789012345678901234567890123456789012345678901234567890123456789 << endl; - return 0; } // tracing ---------------------------------------- @@ -655,11 +654,11 @@ bees_main(int argc, char *argv[]) BeesNote::set_name("bees"); BEESNOTE("main"); - list> all_contexts; - shared_ptr bc; - THROW_CHECK1(invalid_argument, argc, argc >= 0); + // Create a context so we can apply configuration to it + shared_ptr bc = make_shared(); + string cwd(readlink_or_die("/proc/self/cwd")); // Defaults @@ -705,7 +704,7 @@ bees_main(int argc, char *argv[]) // Parse options int c; - while (1) { + while (true) { int option_index = 0; c = getopt_long(argc, argv, getopt_list.c_str(), long_options, &option_index); @@ -756,12 +755,17 @@ bees_main(int argc, char *argv[]) break; case 'h': - do_cmd_help(argv); // fallthrough default: - return 2; + do_cmd_help(argv); + return EXIT_FAILURE; } } + if (optind + 1 != argc) { + BEESLOGERR("Only one filesystem path per bees process"); + return EXIT_FAILURE; + } + Chatter::enable_timestamp(chatter_prefix_timestamp); if (!relative_path().empty()) { @@ -807,18 +811,7 @@ bees_main(int argc, char *argv[]) bc->roots()->set_workaround_btrfs_send(workaround_btrfs_send); // Create a context and start crawlers - bool did_subscription = false; - while (optind < argc) { - catch_all([&]() { - bc = make_shared(bc); - bc->set_root_path(argv[optind++]); - did_subscription = true; - }); - } - - if (!did_subscription) { - BEESLOGWARN("WARNING: no filesystems added"); - } + bc->set_root_path(argv[optind++]); BeesThread status_thread("status", [&]() { bc->dump_status(); @@ -828,7 +821,7 @@ bees_main(int argc, char *argv[]) bc->show_progress(); // That is all. - return 0; + return EXIT_SUCCESS; } int @@ -838,7 +831,7 @@ main(int argc, char *argv[]) if (argc < 2) { do_cmd_help(argv); - return 2; + return EXIT_FAILURE; } int rv = 1;