735 {
736 std::cout << R"(
737 ____ ____ ____
738 | _ \| __ ) | __ ) _ __ _____ _____ ___ _ __
739 | | | | _ \ | _ \| '__/ _ \ \ /\ / / __|/ _ \ '__|
740 | |_| | |_) | | |_) | | | (_) \ V V /\__ \ __/ |
741 |____/|____/ |____/|_| \___/ \_/\_/ |___/\___|_|
742
743 PACS Index Database Browser
744)" << "\n";
745
746 options opts;
747
748 if (!parse_arguments(argc, argv, opts)) {
749 print_usage(argv[0]);
750 return 1;
751 }
752
753
754 if (!fs::exists(opts.db_path)) {
755 std::cerr << "Error: Database file not found: " << opts.db_path << "\n";
756 return 2;
757 }
758
759
760 auto db_result = index_database::open(opts.db_path);
761 if (db_result.is_err()) {
762 std::cerr << "Error: Failed to open database: "
763 << db_result.error().message << "\n";
764 return 2;
765 }
766
767 auto& db = *db_result.value();
768
769
770 switch (opts.command) {
771 case command_type::patients:
772 return list_patients(db, opts);
773 case command_type::studies:
774 return list_studies(db, opts);
775 case command_type::series:
776 return list_series(db, opts);
777 case command_type::instances:
778 return list_instances(db, opts);
779 case command_type::stats:
780 return show_stats(db, opts);
781 case command_type::vacuum:
782 return do_vacuum(db, opts);
783 case command_type::verify: