654{
655 po::options_description desc("Orca Profile Validator\nUsage");
656
657 desc.add_options()("help,h", "help")
658#ifdef __APPLE__
659 ("path,p", po::value<std::string>()->default_value("../../../../../../../resources/profiles"), "profile folder")
660#else
661 ("path,p", po::value<std::string>()->default_value("../../../resources/profiles"), "profile folder")
662#endif
663 ("vendor,v", po::value<std::string>()->default_value(""), "Vendor name. Optional, all profiles present in the folder will be validated if not specified")
664 ("generate_presets,g", po::value<bool>()->default_value(false), "Generate user presets for mock test")
665 ("slice,s", po::bool_switch()->default_value(false), "Slice a two-colour cube through every printer, and through every other system process and filament preset whose templates no printer's own slice expands, so every custom g-code and filename_format shipped is expanded, names in {if} branches not taken included (catches placeholder/flow errors that static checks miss). Off unless this flag is present.")
666 ("outdir,o", po::value<std::string>()->default_value(""), "With -s, also save each slice's g-code to this folder (as <vendor>__<printer>[__<preset>].gcode) for manual inspection. Optional.")
667 ("check_filament_subtypes,f", po::bool_switch()->default_value(true), "Also flag printers with duplicate (ambiguous) filament subtypes. Off unless this flag is present.")
668 ("log_level,l", po::value<int>()->default_value(2), "Log level. Optional, default is 2 (warning). Higher values produce more detailed logs.");
669
670
671 po::variables_map vm;
672 try {
673 po::store(po::parse_command_line(argc, argv, desc), vm);
674
675 if (vm.count("help")) {
676 std::cout << desc << "\n";
677 return 1;
678 }
679
680 po::notify(vm);
681 } catch (const po::error& e) {
682 std::cerr << "Error: " << e.what() << "\n";
683 std::cerr << desc << "\n";
684 return 1;
685 }
686
687 std::string path = vm["path"].as<std::string>();
688 std::string vendor = vm["vendor"].as<std::string>();
689 int log_level = vm["log_level"].as<int>();
690 bool generate_user_preset = vm["generate_presets"].as<bool>();
691 bool slice_mode = vm["slice"].as<bool>();
692 std::string slice_outdir = vm["outdir"].as<std::string>();
693 bool check_filament_subtypes = vm["check_filament_subtypes"].as<bool>();
694
695
696 if (!fs::exists(path) || !fs::is_directory(path)) {
697 std::cerr << "Error: " << path << " is not a valid directory\n";
698 return 1;
699 }
700
701
702
703
704
706
707
708
709
710 if (fs::exists(fs::path(path).parent_path() / "info"))
712
714 user_dir.make_preferred();
715 if (!fs::exists(user_dir))
716 fs::create_directory(user_dir);
717
719
720
721
722 if (slice_mode)
724
726
727 preset_bundle->set_is_validation_mode(true);
728 preset_bundle->set_vendor_to_validate(vendor);
729
730 preset_bundle->set_default_suppressed(true);
732 app_config.
set(
"preset_folder",
"default");
733
734 if(generate_user_preset)
735 preset_bundle->remove_user_presets_directory("default");
736
737 try {
738 auto preset_substitutions = preset_bundle->load_presets(app_config, ForwardCompatibilitySubstitutionRule::Disable);
739 } catch (const std::exception& ex) {
740 BOOST_LOG_TRIVIAL(error) << ex.what();
741 std::cout << "Validation failed" << std::endl;
742 return 1;
743 }
744
745 std::cout << "Total loaded vendors: " << preset_bundle->vendors.size() << std::endl;
746
747 if (generate_user_preset) {
749 return 0;
750 }
751
752 if (preset_bundle->has_errors(check_filament_subtypes)) {
753 std::cout << "Validation failed" << std::endl;
754 return 1;
755 }
756
757 std::cout << "Validation completed successfully" << std::endl;
758 return 0;
759}
void generate_custom_presets(PresetBundle *preset_bundle, AppConfig &app_config)
Definition OrcaSlicer_profile_validator.cpp:68
Definition AppConfig.hpp:100
void set(const std::string §ion, const std::string &key, const std::string &value)
Definition AppConfig.hpp:167
Definition PresetBundle.hpp:210
void set_data_dir(const std::string &dir)
Definition utils.cpp:353
void set_logging_level(unsigned int level)
Definition utils.cpp:171
void set_resources_dir(const std::string &dir)
Definition utils.cpp:291
int slice_all_printers(const std::string &vendor, const std::string &outdir)
Definition OrcaSlicer_profile_validator.cpp:449