#pragma once #include #include namespace smartbotic::common { struct ConfigArg { std::filesystem::path path; /** * True when the caller named a config file on the command line, false when * the built-in default path is being used. * * The distinction decides what a missing file means. Falling back to * defaults is reasonable when nobody asked for a particular file; it is * never reasonable when someone did, because the settings they meant to * apply - database address, project namespace, ports - would be silently * replaced by other values. */ bool explicitly_given = false; }; /** * Read the config file location from a service's command line. * * Accepts, in order of preference: * --config --config= * -c -c= * (bare first argument, the original form) * * The flag forms exist because the packaged systemd units have always passed * "--config /etc/.../webserver.json", while the services only ever read * argv[1] as a path. That mismatch made every .deb install run on built-in * defaults with nothing but a warning to say so. * * Unknown arguments are ignored rather than rejected, so this stays additive * for anything else a deployment may already be passing. */ ConfigArg parseConfigArg(int argc, char* argv[], const std::filesystem::path& default_path); } // namespace smartbotic::common