Added ignore_validation flag check and CLI argument

This commit is contained in:
David Allen 2024-08-18 13:42:02 -06:00
parent e8020aa0b0
commit a6635b1f02
Signed by: towk
GPG key ID: 793B2924A49B3A3F

View file

@ -147,6 +147,13 @@ namespace gdpm::package_manager{
.help("set verbosity level")
.nargs(nargs_pattern::optional);
program.add_argument("--ignore-validation")
.action([&](const auto&){ config.ignore_validation = true; })
.default_value(false)
.implicit_value(true)
.help("ignore checking if current directory is a Godot project")
.nargs(0);
install_command.add_description("install package(s)");
install_command.add_argument("packages")
.required()
@ -409,6 +416,13 @@ namespace gdpm::package_manager{
return log::error_rc(ec::ARGPARSE_ERROR, e.what());
}
/* Check if we're running in a directory with 'project.godot' file */
if (!config.ignore_validation) {
if(!std::filesystem::exists("project.godot")){
return error(ec::FILE_NOT_FOUND, "no 'project.godot' file found in current directory");
}
}
if(program.is_subcommand_used(install_command)){
action = action_e::install;
// if(install_command.is_used("packages"))