mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-29 11:19:07 +08:00
[commands] Use Checks::exit_fail/success/with_code()
This commit is contained in:
parent
27bc606020
commit
4bc91f1f26
@ -126,11 +126,8 @@ namespace vcpkg::Commands::Build
|
||||
if (options.find(OPTION_CHECKS_ONLY) != options.end())
|
||||
{
|
||||
const size_t error_count = PostBuildLint::perform_all_checks(spec, paths);
|
||||
if (error_count > 0)
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::check_exit(VCPKG_LINE_INFO, error_count == 0);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
const expected<SourceParagraph> maybe_spgh = Paragraphs::try_load_port(port_dir);
|
||||
@ -158,17 +155,17 @@ namespace vcpkg::Commands::Build
|
||||
System::println(" %s", p.spec.toString());
|
||||
}
|
||||
System::println("");
|
||||
exit(EXIT_FAILURE);
|
||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
if (result != BuildResult::SUCCEEDED)
|
||||
{
|
||||
System::println(System::color::error, Build::create_error_message(result, spec));
|
||||
System::println(Build::create_user_troubleshooting_message(spec));
|
||||
exit(EXIT_FAILURE);
|
||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
|
||||
|
@ -46,7 +46,7 @@ namespace vcpkg::Commands::Cache
|
||||
if (binary_paragraphs.empty())
|
||||
{
|
||||
System::println("No packages are cached.");
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
if (args.command_arguments.size() == 0)
|
||||
@ -72,6 +72,6 @@ namespace vcpkg::Commands::Cache
|
||||
}
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,6 @@ namespace vcpkg::Commands::CI
|
||||
System::println(" %s: %d", Build::to_string(entry.first), entry.second);
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ namespace vcpkg::Commands::Contact
|
||||
args.check_and_get_optional_command_arguments({});
|
||||
|
||||
System::println("Send an email to %s with any feedback.", email());
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,6 @@ namespace vcpkg::Commands::Create
|
||||
}
|
||||
|
||||
const std::wstring cmd_launch_cmake = make_cmake_cmd(cmake_exe, paths.ports_cmake, cmake_args);
|
||||
exit(System::cmd_execute_clean(cmd_launch_cmake));
|
||||
Checks::exit_with_code(VCPKG_LINE_INFO, System::cmd_execute_clean(cmd_launch_cmake));
|
||||
}
|
||||
}
|
||||
|
@ -72,6 +72,6 @@ namespace vcpkg::Commands::Edit
|
||||
}
|
||||
|
||||
std::wstring cmdLine = Strings::wformat(LR"("%s" "%s" "%s" -n)", env_EDITOR, portpath.native(), (portpath / "portfile.cmake").native());
|
||||
exit(System::cmd_execute(cmdLine));
|
||||
Checks::exit_with_code(VCPKG_LINE_INFO, System::cmd_execute(cmdLine));
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,6 @@ namespace vcpkg::Commands::Hash
|
||||
do_file_hash(args.command_arguments[0], Strings::utf8_to_utf16(args.command_arguments[1]));
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ namespace vcpkg::Commands::Help
|
||||
if (args.command_arguments.empty())
|
||||
{
|
||||
print_usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
const auto& topic = args.command_arguments[0];
|
||||
if (topic == "triplet")
|
||||
@ -83,8 +83,8 @@ namespace vcpkg::Commands::Help
|
||||
{
|
||||
System::println(System::color::error, "Error: unknown topic %s", topic);
|
||||
print_usage();
|
||||
exit(EXIT_FAILURE);
|
||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +80,6 @@ namespace vcpkg::Commands::Import
|
||||
auto& control_file_data = spgh.package;
|
||||
|
||||
do_import(paths, include_directory, project_directory, control_file_data);
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ namespace vcpkg::Commands::Install
|
||||
System::print("\n ");
|
||||
System::println(Strings::join("\n ", intersection));
|
||||
System::println("");
|
||||
exit(EXIT_FAILURE);
|
||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
StatusParagraph spgh;
|
||||
@ -221,7 +221,7 @@ namespace vcpkg::Commands::Install
|
||||
{
|
||||
System::println(System::color::error, Build::create_error_message(result, action.spec));
|
||||
System::println(Build::create_user_troubleshooting_message(action.spec));
|
||||
exit(EXIT_FAILURE);
|
||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||
}
|
||||
const BinaryParagraph bpgh = Paragraphs::try_load_cached_package(paths, action.spec).get_or_throw(VCPKG_LINE_INFO);
|
||||
install_package(paths, bpgh, &status_db);
|
||||
@ -238,10 +238,10 @@ namespace vcpkg::Commands::Install
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
System::println(System::color::error, "Error: Could not install package %s: %s", action.spec, e.what());
|
||||
exit(EXIT_FAILURE);
|
||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ namespace vcpkg::Commands::Integrate
|
||||
break;
|
||||
case elevation_prompt_user_choice::no:
|
||||
System::println(System::color::warning, "Warning: Previous integration file was not removed");
|
||||
exit(EXIT_FAILURE);
|
||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||
default:
|
||||
Checks::unreachable(VCPKG_LINE_INFO);
|
||||
}
|
||||
@ -193,7 +193,7 @@ namespace vcpkg::Commands::Integrate
|
||||
break;
|
||||
case elevation_prompt_user_choice::no:
|
||||
System::println(System::color::warning, "Warning: integration was not applied");
|
||||
exit(EXIT_FAILURE);
|
||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||
default:
|
||||
Checks::unreachable(VCPKG_LINE_INFO);
|
||||
}
|
||||
@ -208,7 +208,7 @@ namespace vcpkg::Commands::Integrate
|
||||
if (!fs::copy_file(appdata_src_path, appdata_dst_path, fs::copy_options::overwrite_existing))
|
||||
{
|
||||
System::println(System::color::error, "Error: Failed to copy file: %s -> %s", appdata_src_path.string(), appdata_dst_path.string());
|
||||
exit(EXIT_FAILURE);
|
||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||
}
|
||||
System::println(System::color::success, "Applied user-wide integration for this vcpkg root.");
|
||||
const fs::path cmake_toolchain = paths.buildsystems / "vcpkg.cmake";
|
||||
@ -219,7 +219,7 @@ namespace vcpkg::Commands::Integrate
|
||||
"\n"
|
||||
"CMake projects should use -DCMAKE_TOOLCHAIN_FILE=%s", cmake_toolchain.generic_string());
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
static void integrate_remove()
|
||||
@ -240,7 +240,7 @@ namespace vcpkg::Commands::Integrate
|
||||
System::println(System::color::success, "User-wide integration is not installed");
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
static void integrate_project(const vcpkg_paths& paths)
|
||||
@ -276,7 +276,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console
|
||||
Install-Package %s -Source "%s"
|
||||
)", nuget_id, buildsystems_dir.generic_string());
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
const char* const INTEGRATE_COMMAND_HELPSTRING =
|
||||
|
@ -33,7 +33,7 @@ namespace vcpkg::Commands::List
|
||||
if (installed_packages.empty())
|
||||
{
|
||||
System::println("No packages are installed. Did you mean `search`?");
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
std::sort(installed_packages.begin(), installed_packages.end(),
|
||||
@ -64,6 +64,6 @@ namespace vcpkg::Commands::List
|
||||
}
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,6 @@ namespace vcpkg::Commands::Owns
|
||||
|
||||
StatusParagraphs status_db = database_load_check(paths);
|
||||
search_file(paths, args.command_arguments[0], status_db);
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
@ -133,6 +133,6 @@ namespace vcpkg::Commands::PortsDiff
|
||||
System::println("There were no changes in the ports between the two commits.");
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ namespace vcpkg::Commands::Remove
|
||||
System::println(System::color::warning,
|
||||
"Additional packages (*) need to be removed to complete this operation.\n"
|
||||
"If you are sure you want to remove them, run the command with the --recurse option");
|
||||
exit(EXIT_FAILURE);
|
||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
for (const package_spec_with_remove_plan& action : remove_plan)
|
||||
@ -219,6 +219,6 @@ namespace vcpkg::Commands::Remove
|
||||
}
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ namespace vcpkg::Commands::Search
|
||||
{
|
||||
const std::string graph_as_string = create_graph_as_string(source_paragraphs);
|
||||
System::println(graph_as_string);
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
if (args.command_arguments.empty())
|
||||
@ -91,6 +91,6 @@ namespace vcpkg::Commands::Search
|
||||
System::println("\nIf your library is not listed, please open an issue at and/or consider making a pull request:\n"
|
||||
" https://github.com/Microsoft/vcpkg/issues");
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +75,6 @@ namespace vcpkg::Commands::Update
|
||||
}
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,6 @@ namespace vcpkg::Commands::Version
|
||||
"\n"
|
||||
"See LICENSE.txt for license information.", version()
|
||||
);
|
||||
exit(EXIT_SUCCESS);
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user