#include "parseargs.hh" #include #include #include constexpr int DEFAULT_ITERATIONS = 2000; using path = std::filesystem::path; namespace po = boost::program_options; void processFilenames(po::variables_map const& vm, path const& t_input, path& t_output) { if (!vm.count("output")) { t_output.replace_filename("output_" + std::string{t_input.filename().string()}); } else if (!t_output.has_extension()) { t_output.replace_extension(".png"); } } [[nodiscard]] auto parse_args(int t_ac, char** t_av) -> std::tuple { po::options_description desc("Allowed options"); desc.add_options() ("help,h", "Display this help message") ("input,i", po::value(), "Input image") ("output,o", po::value(), "Image output path (default: \"output_\" + input path)") ("iterations,n", po::value(), "Number of iterations (default: 2000)") ("method,m", po::value(), "Method number to be used (default: 1)") ("cols,c", po::value(), "For method 5 only, number of columns the reference image should be " "divided into. If the value is equal to 0, then it will be assumed " "there will be as many rows as there are collumns. (default: 0)") ("rows,r", po::value(), "For method 5 only, number of rows the reference image should be " "divided into. (default: 1)") ("submethod,S", po::value(), "Sub-method that will be used to generate the individual tiles from " "method 5. (default: 1)") ("size,s", "Enables controlled size of the random shapes") ("verbose,v", "Enables verbosity"); po::variables_map vm; po::store(po::parse_command_line(t_ac, t_av, desc), vm); po::notify(vm); if (vm.count("help") || !vm.count("input")) { std::cout << desc << "\n"; std::exit(!vm.count("help")); } auto const input_path = vm["input"].as(); auto output_path = vm.count("output") ? vm["output"].as() : input_path.filename(); processFilenames(vm, input_path, output_path); return std::make_tuple( input_path, output_path, vm.count("iterations") ? vm["iterations"].as() : DEFAULT_ITERATIONS, vm.count("method") ? vm["method"].as() : 1, vm.count("cols") ? vm["cols"].as() : 0, vm.count("rows") ? vm["rows"].as() : 1, vm.count("submethod") ? vm["submethod"].as() : 1, vm.count("size"), vm.count("verbose")); }