From e07cc42fb2fa3318f11c88351de35b0a821d9ca9 Mon Sep 17 00:00:00 2001 From: Javier Matos Date: Tue, 19 Jul 2022 14:28:28 -0700 Subject: [PATCH 01/14] FailedToParseManifest FailedToReadParagraph MissingArgFormatManifest FailedToRemoveControl FailedToWriteManifest --- include/vcpkg/base/messages.h | 18 ++++++++++++-- locales/messages.en.json | 11 +++++++-- locales/messages.json | 20 ++++++++++++--- src/vcpkg/base/json.cpp | 6 ++--- src/vcpkg/base/messages.cpp | 11 +++++++-- src/vcpkg/commands.format-manifest.cpp | 34 ++++++++++++++------------ 6 files changed, 72 insertions(+), 28 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 8b9388773e..9f777ee7e7 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -915,8 +915,8 @@ namespace vcpkg (msg::actual), "{actual} is the provided format string", "invalid format string: {actual}"); - DECLARE_MESSAGE(JsonErrorFailedToParse, (msg::path), "", "failed to parse {path}:"); - DECLARE_MESSAGE(JsonErrorFailedToRead, (msg::path, msg::error_msg), "", "failed to read {path}: {error_msg}"); + DECLARE_MESSAGE(FailedToParseJson, (msg::path), "", "Failed to parse JSON file {path}"); + DECLARE_MESSAGE(FailedToRead, (msg::path, msg::error_msg), "", "Failed to read {path}: {error_msg}"); DECLARE_MESSAGE(JsonErrorMustBeAnObject, (msg::path), "", "Expected \"{path}\" to be an object."); DECLARE_MESSAGE(LaunchingProgramFailed, (msg::tool_name), @@ -1282,4 +1282,18 @@ namespace vcpkg "The message named {value} starts with warning:, it must be changed to prepend " "WarningMessage in code instead."); DECLARE_MESSAGE(WarningsTreatedAsErrors, (), "", "previous warnings being interpreted as errors"); + DECLARE_MESSAGE(FailedToParseManifest, (msg::path), "", "Failed to parse manifest file: \"{path}\""); + DECLARE_MESSAGE(FailedToReadParagraph, (msg::path), "", "Failed to read paragraphs from \"{path}\""); + DECLARE_MESSAGE(FailedToParseControl, (msg::path), "", "Failed to parse control file: \"{path}\""); + DECLARE_MESSAGE(FailedToWriteManifest, (msg::path), "", "Failed to write manifest file \"{path}\""); + DECLARE_MESSAGE(FailedToRemoveControl, (msg::path), "", "Failed to remove control file \"{path}\""); + DECLARE_MESSAGE(FailedToFormatMissingFile, + (), + "", + "No files to format.\nPlease pass either --all, or the explicit files to format or convert."); + DECLARE_MESSAGE(MissingArgFormatManifest, + (), + "", + "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: we will " + "automatically convert all control files passed explicitly."); } diff --git a/locales/messages.en.json b/locales/messages.en.json index 79df3b0828..ffc2b485fb 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -113,11 +113,19 @@ "ExpectedTripletName": "expected a triplet name here", "ExtendedDocumenationAtUrl": "Extended documentation available at '{url}'.", "FailedToExtract": "Failed to extract \"{path}\":", + "FailedToFormatMissingFile": "No files to format.\nPlease pass either --all, or the explicit files to format or convert.", "FailedToParseCMakeConsoleOut": "Failed to parse CMake console output to locate block start/end markers.", + "FailedToParseControl": "Failed to parse control file: \"{path}\"", + "FailedToParseJson": "Failed to parse JSON file {path}", + "FailedToParseManifest": "Failed to parse manifest file: \"{path}\"", "FailedToProvisionCe": "Failed to provision vcpkg-ce.", + "FailedToRead": "Failed to read {path}: {error_msg}", + "FailedToReadParagraph": "Failed to read paragraphs from \"{path}\"", + "FailedToRemoveControl": "Failed to remove control file \"{path}\"", "FailedToRunToolToDetermineVersion": "Failed to run \"{path}\" to determine the {tool_name} version.", "FailedToStoreBackToMirror": "failed to store back to mirror:", "FailedToStoreBinaryCache": "Failed to store binary cache {path}", + "FailedToWriteManifest": "Failed to write manifest file \"{path}\"", "FailedVendorAuthentication": "One or more {vendor} credential providers failed to authenticate. See '{url}' for more details on how to provide credentials.", "FishCompletion": "vcpkg fish completion is already added at \"{path}\".", "ForceSystemBinariesOnWeirdPlatforms": "Environment variable VCPKG_FORCE_SYSTEM_BINARIES must be set on arm, s390x, and ppc64le platforms.", @@ -161,8 +169,6 @@ "InvalidArgumentRequiresTwoOrThreeArguments": "invalid argument: binary config '{binary_source}' requires 2 or 3 arguments", "InvalidArgumentRequiresValidToken": "invalid argument: binary config '{binary_source}' requires a SAS token without a preceeding '?' as the second argument", "InvalidFormatString": "invalid format string: {actual}", - "JsonErrorFailedToParse": "failed to parse {path}:", - "JsonErrorFailedToRead": "failed to read {path}: {error_msg}", "JsonErrorMustBeAnObject": "Expected \"{path}\" to be an object.", "LaunchingProgramFailed": "Launching {tool_name}:", "LicenseExpressionContainsExtraPlus": "SPDX license expression contains an extra '+'. These are only allowed directly after a license identifier.", @@ -188,6 +194,7 @@ "LocalizedMessageMustNotContainIndents": "The message named {value} contains what appears to be indenting which must be changed to use LocalizedString::append_indent instead.", "LocalizedMessageMustNotEndWithNewline": "The message named {value} ends with a newline which should be added by formatting rather than by localization.", "Missing7zHeader": "Unable to find 7z header.", + "MissingArgFormatManifest": "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: we will automatically convert all control files passed explicitly.", "MissingExtension": "Missing '{extension}' extension.", "MonoInstructions": "This may be caused by an incomplete mono installation. Full mono is available on some systems via `sudo apt install mono-complete`. Ubuntu 18.04 users may need a newer version of mono, available at https://www.mono-project.com/download/stable/", "MsiexecFailedToExtract": "msiexec failed while extracting \"{path}\" with launch or exit code {exit_code} and message:", diff --git a/locales/messages.json b/locales/messages.json index a1b2a5c287..7e35cfa45e 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -201,13 +201,28 @@ "_ExtendedDocumenationAtUrl.comment": "An example of {url} is https://github.com/microsoft/vcpkg.", "FailedToExtract": "Failed to extract \"{path}\":", "_FailedToExtract.comment": "An example of {path} is /foo/bar.", + "FailedToFormatMissingFile": "No files to format.\nPlease pass either --all, or the explicit files to format or convert.", "FailedToParseCMakeConsoleOut": "Failed to parse CMake console output to locate block start/end markers.", + "FailedToParseControl": "Failed to parse control file: \"{path}\"", + "_FailedToParseControl.comment": "An example of {path} is /foo/bar.", + "FailedToParseJson": "Failed to parse JSON file {path}", + "_FailedToParseJson.comment": "An example of {path} is /foo/bar.", + "FailedToParseManifest": "Failed to parse manifest file: \"{path}\"", + "_FailedToParseManifest.comment": "An example of {path} is /foo/bar.", "FailedToProvisionCe": "Failed to provision vcpkg-ce.", + "FailedToRead": "Failed to read {path}: {error_msg}", + "_FailedToRead.comment": "An example of {path} is /foo/bar. An example of {error_msg} is File Not Found.", + "FailedToReadParagraph": "Failed to read paragraphs from \"{path}\"", + "_FailedToReadParagraph.comment": "An example of {path} is /foo/bar.", + "FailedToRemoveControl": "Failed to remove control file \"{path}\"", + "_FailedToRemoveControl.comment": "An example of {path} is /foo/bar.", "FailedToRunToolToDetermineVersion": "Failed to run \"{path}\" to determine the {tool_name} version.", "_FailedToRunToolToDetermineVersion.comment": "Additional information, such as the command line output, if any, will be appended on the line after this message An example of {tool_name} is aria2. An example of {path} is /foo/bar.", "FailedToStoreBackToMirror": "failed to store back to mirror:", "FailedToStoreBinaryCache": "Failed to store binary cache {path}", "_FailedToStoreBinaryCache.comment": "An example of {path} is /foo/bar.", + "FailedToWriteManifest": "Failed to write manifest file \"{path}\"", + "_FailedToWriteManifest.comment": "An example of {path} is /foo/bar.", "FailedVendorAuthentication": "One or more {vendor} credential providers failed to authenticate. See '{url}' for more details on how to provide credentials.", "_FailedVendorAuthentication.comment": "An example of {vendor} is Azure. An example of {url} is https://github.com/microsoft/vcpkg.", "FishCompletion": "vcpkg fish completion is already added at \"{path}\".", @@ -282,10 +297,6 @@ "_InvalidArgumentRequiresValidToken.comment": "An example of {binary_source} is azblob.", "InvalidFormatString": "invalid format string: {actual}", "_InvalidFormatString.comment": "{actual} is the provided format string", - "JsonErrorFailedToParse": "failed to parse {path}:", - "_JsonErrorFailedToParse.comment": "An example of {path} is /foo/bar.", - "JsonErrorFailedToRead": "failed to read {path}: {error_msg}", - "_JsonErrorFailedToRead.comment": "An example of {path} is /foo/bar. An example of {error_msg} is File Not Found.", "JsonErrorMustBeAnObject": "Expected \"{path}\" to be an object.", "_JsonErrorMustBeAnObject.comment": "An example of {path} is /foo/bar.", "LaunchingProgramFailed": "Launching {tool_name}:", @@ -327,6 +338,7 @@ "LocalizedMessageMustNotEndWithNewline": "The message named {value} ends with a newline which should be added by formatting rather than by localization.", "_LocalizedMessageMustNotEndWithNewline.comment": "{value} is a localized message name like LocalizedMessageMustNotEndWithNewline", "Missing7zHeader": "Unable to find 7z header.", + "MissingArgFormatManifest": "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: we will automatically convert all control files passed explicitly.", "MissingExtension": "Missing '{extension}' extension.", "_MissingExtension.comment": "An example of {extension} is .exe.", "MonoInstructions": "This may be caused by an incomplete mono installation. Full mono is available on some systems via `sudo apt install mono-complete`. Ubuntu 18.04 users may need a newer version of mono, available at https://www.mono-project.com/download/stable/", diff --git a/src/vcpkg/base/json.cpp b/src/vcpkg/base/json.cpp index 10a95df93d..dab95a2924 100644 --- a/src/vcpkg/base/json.cpp +++ b/src/vcpkg/base/json.cpp @@ -1096,12 +1096,12 @@ namespace vcpkg::Json auto ret = parse_file(fs, json_file, ec); if (ec) { - msg::println_error(msgJsonErrorFailedToRead, msg::path = json_file, msg::error_msg = ec); + msg::println_error(msgFailedToRead, msg::path = json_file, msg::error_msg = ec); Checks::exit_fail(li); } else if (!ret) { - msg::println_error(msgJsonErrorFailedToParse, msg::path = json_file); + msg::println_error(msgFailedToParseJson, msg::path = json_file); msg::write_unlocalized_text_to_stdout(Color::error, ret.error()->to_string()); msg::println(); Checks::exit_fail(li); @@ -1128,7 +1128,7 @@ namespace vcpkg::Json return msg::format(msgJsonErrorMustBeAnObject, msg::path = origin).extract_data(); } - return msg::format(msgJsonErrorFailedToParse, msg::path = origin) + return msg::format(msgFailedToParseJson, msg::path = origin) .append_raw("\n") .append_raw(maybeValueIsh.error()->to_string()) .extract_data(); diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index bd5c8da46b..65ea32a43e 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -561,8 +561,8 @@ namespace vcpkg REGISTER_MESSAGE(InvalidArgumentRequiresTwoOrThreeArguments); REGISTER_MESSAGE(InvalidArgumentRequiresValidToken); REGISTER_MESSAGE(InvalidFormatString); - REGISTER_MESSAGE(JsonErrorFailedToParse); - REGISTER_MESSAGE(JsonErrorFailedToRead); + REGISTER_MESSAGE(FailedToParseJson); + REGISTER_MESSAGE(FailedToRead); REGISTER_MESSAGE(JsonErrorMustBeAnObject); REGISTER_MESSAGE(LaunchingProgramFailed); REGISTER_MESSAGE(LicenseExpressionContainsExtraPlus); @@ -671,4 +671,11 @@ namespace vcpkg REGISTER_MESSAGE(WaitingToTakeFilesystemLock); REGISTER_MESSAGE(WarningMessageMustUsePrintWarning); REGISTER_MESSAGE(WarningsTreatedAsErrors); + REGISTER_MESSAGE(FailedToParseManifest); + REGISTER_MESSAGE(FailedToReadParagraph); + REGISTER_MESSAGE(MissingArgFormatManifest); + REGISTER_MESSAGE(FailedToRemoveControl); + REGISTER_MESSAGE(FailedToWriteManifest); + REGISTER_MESSAGE(FailedToParseControl); + REGISTER_MESSAGE(FailedToFormatMissingFile); } diff --git a/src/vcpkg/commands.format-manifest.cpp b/src/vcpkg/commands.format-manifest.cpp index 94ee8051ae..8648af4075 100644 --- a/src/vcpkg/commands.format-manifest.cpp +++ b/src/vcpkg/commands.format-manifest.cpp @@ -31,14 +31,16 @@ namespace auto parsed_json_opt = Json::parse(contents, manifest_path); if (!parsed_json_opt) { - vcpkg::printf(Color::error, "Failed to parse %s: %s\n", path_string, parsed_json_opt.error()->to_string()); + msg::println_error(msg::format(msgFailedToParseJson, msg::path = path_string) + .append_raw(": ") + .append_raw(parsed_json_opt.error()->to_string())); return nullopt; } const auto& parsed_json = parsed_json_opt.value_or_exit(VCPKG_LINE_INFO).first; if (!parsed_json.is_object()) { - vcpkg::printf(Color::error, "The file %s is not an object\n", path_string); + msg::println_error(msgJsonErrorMustBeAnObject, msg::path = path_string); return nullopt; } @@ -47,7 +49,7 @@ namespace auto scf = SourceControlFile::parse_project_manifest_object(path_string, parsed_json_obj, stdout_sink); if (!scf) { - vcpkg::printf(Color::error, "Failed to parse manifest file: %s\n", path_string); + msg::println_error(msgFailedToParseManifest, msg::path = path_string); print_error_message(scf.error()); return nullopt; } @@ -70,14 +72,16 @@ namespace if (!paragraphs) { - vcpkg::printf(Color::error, "Failed to read paragraphs from %s: %s\n", control_path, paragraphs.error()); + msg::println_error(msg::format(msgFailedToReadParagraph, msg::path = control_path) + .append_raw(": ") + .append_raw(paragraphs.error())); return {}; } auto scf_res = SourceControlFile::parse_control_file(control_path, std::move(paragraphs).value_or_exit(VCPKG_LINE_INFO)); if (!scf_res) { - vcpkg::printf(Color::error, "Failed to parse control file: %s\n", control_path); + msg::println_error(msgFailedToParseControl, msg::path = control_path); print_error_message(scf_res.error()); return {}; } @@ -152,16 +156,20 @@ Please open an issue at https://github.com/microsoft/vcpkg, with the following o fs.write_contents(data.file_to_write, Json::stringify(res), ec); if (ec) { - Checks::exit_with_message( - VCPKG_LINE_INFO, "Failed to write manifest file %s: %s\n", file_to_write_string, ec.message()); + Checks::msg_exit_with_message(VCPKG_LINE_INFO, + msg::format(msgFailedToWriteManifest, msg::path = file_to_write_string) + .append_raw(": ") + .append_raw(ec.message())); } if (data.original_path != data.file_to_write) { fs.remove(data.original_path, ec); if (ec) { - Checks::exit_with_message( - VCPKG_LINE_INFO, "Failed to remove control file %s: %s\n", original_path_string, ec.message()); + Checks::msg_exit_with_message(VCPKG_LINE_INFO, + msg::format(msgFailedToRemoveControl, msg::path = original_path_string) + .append_raw(": ") + .append_raw(ec.message())); } } } @@ -197,16 +205,12 @@ namespace vcpkg::Commands::FormatManifest if (!format_all && convert_control) { - print2(Color::warning, R"(format-manifest was passed '--convert-control' without '--all'. - This doesn't do anything: - we will automatically convert all control files passed explicitly.)"); + msg::println_warning(msgMissingArgFormatManifest); } if (!format_all && args.command_arguments.empty()) { - Checks::exit_with_message( - VCPKG_LINE_INFO, - "No files to format; please pass either --all, or the explicit files to format or convert."); + Checks::msg_exit_with_message(VCPKG_LINE_INFO, msgFailedToFormatMissingFile); } std::vector to_write; From 0d2151d126b2f66bc15733ba2fed4ec2d46c3e8f Mon Sep 17 00:00:00 2001 From: Javier Matos Date: Wed, 20 Jul 2022 11:02:32 -0700 Subject: [PATCH 02/14] FailedToParseManifest FailedToReadParagraph FailedToParseControl FailedToWriteManifest FailedToRemoveControl --- include/vcpkg/base/messages.h | 14 +++++++++----- locales/messages.en.json | 11 ++++++----- locales/messages.json | 12 +++++++----- src/vcpkg/base/messages.cpp | 1 + src/vcpkg/commands.format-manifest.cpp | 8 ++++---- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 9f777ee7e7..0ea7cf0dce 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -1282,11 +1282,11 @@ namespace vcpkg "The message named {value} starts with warning:, it must be changed to prepend " "WarningMessage in code instead."); DECLARE_MESSAGE(WarningsTreatedAsErrors, (), "", "previous warnings being interpreted as errors"); - DECLARE_MESSAGE(FailedToParseManifest, (msg::path), "", "Failed to parse manifest file: \"{path}\""); - DECLARE_MESSAGE(FailedToReadParagraph, (msg::path), "", "Failed to read paragraphs from \"{path}\""); - DECLARE_MESSAGE(FailedToParseControl, (msg::path), "", "Failed to parse control file: \"{path}\""); - DECLARE_MESSAGE(FailedToWriteManifest, (msg::path), "", "Failed to write manifest file \"{path}\""); - DECLARE_MESSAGE(FailedToRemoveControl, (msg::path), "", "Failed to remove control file \"{path}\""); + DECLARE_MESSAGE(FailedToParseManifest, (msg::path), "", "Failed to parse manifest file: {path}"); + DECLARE_MESSAGE(FailedToReadParagraph, (msg::path), "", "Failed to read paragraphs from {path}"); + DECLARE_MESSAGE(FailedToParseControl, (msg::path), "", "Failed to parse control file: {path}"); + DECLARE_MESSAGE(FailedToWriteManifest, (msg::path), "", "Failed to write manifest file {path}"); + DECLARE_MESSAGE(FailedToRemoveControl, (msg::path), "", "Failed to remove control file {path}"); DECLARE_MESSAGE(FailedToFormatMissingFile, (), "", @@ -1296,4 +1296,8 @@ namespace vcpkg "", "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: we will " "automatically convert all control files passed explicitly."); + DECLARE_MESSAGE(ControlAndManifestFilesPresent, + (msg::path), + "", + "Both a manifest file and a CONTROL file exist in port directory: {path}"); } diff --git a/locales/messages.en.json b/locales/messages.en.json index ffc2b485fb..47984768af 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -77,6 +77,7 @@ "CmakeTargetsExcluded": "note: {count} additional targets are not displayed.", "CommandFailed": "command:\n{command_line}\nfailed with the following results:", "CompressFolderFailed": "Failed to compress folder \"{path}\":", + "ControlAndManifestFilesPresent": "Both a manifest file and a CONTROL file exist in port directory: {path}", "CouldNotDeduceNugetIdAndVersion": "Could not deduce nuget id and version from filename: {path}", "CreatedNuGetPackage": "Created nupkg: \"{path}\"", "CurlReportedUnexpectedResults": "curl has reported unexpected results to vcpkg and vcpkg cannot continue.\nPlease review the following text for sensitive information and open an issue on the Microsoft/vcpkg GitHub to help fix this problem!\ncmd: {command_line}\n=== curl output ===\n{actual}\n=== end curl output ===", @@ -115,17 +116,17 @@ "FailedToExtract": "Failed to extract \"{path}\":", "FailedToFormatMissingFile": "No files to format.\nPlease pass either --all, or the explicit files to format or convert.", "FailedToParseCMakeConsoleOut": "Failed to parse CMake console output to locate block start/end markers.", - "FailedToParseControl": "Failed to parse control file: \"{path}\"", + "FailedToParseControl": "Failed to parse control file: {path}", "FailedToParseJson": "Failed to parse JSON file {path}", - "FailedToParseManifest": "Failed to parse manifest file: \"{path}\"", + "FailedToParseManifest": "Failed to parse manifest file: {path}", "FailedToProvisionCe": "Failed to provision vcpkg-ce.", "FailedToRead": "Failed to read {path}: {error_msg}", - "FailedToReadParagraph": "Failed to read paragraphs from \"{path}\"", - "FailedToRemoveControl": "Failed to remove control file \"{path}\"", + "FailedToReadParagraph": "Failed to read paragraphs from {path}", + "FailedToRemoveControl": "Failed to remove control file {path}", "FailedToRunToolToDetermineVersion": "Failed to run \"{path}\" to determine the {tool_name} version.", "FailedToStoreBackToMirror": "failed to store back to mirror:", "FailedToStoreBinaryCache": "Failed to store binary cache {path}", - "FailedToWriteManifest": "Failed to write manifest file \"{path}\"", + "FailedToWriteManifest": "Failed to write manifest file {path}", "FailedVendorAuthentication": "One or more {vendor} credential providers failed to authenticate. See '{url}' for more details on how to provide credentials.", "FishCompletion": "vcpkg fish completion is already added at \"{path}\".", "ForceSystemBinariesOnWeirdPlatforms": "Environment variable VCPKG_FORCE_SYSTEM_BINARIES must be set on arm, s390x, and ppc64le platforms.", diff --git a/locales/messages.json b/locales/messages.json index 7e35cfa45e..5a5cb2b8f3 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -140,6 +140,8 @@ "_CommandFailed.comment": "An example of {command_line} is vcpkg install zlib.", "CompressFolderFailed": "Failed to compress folder \"{path}\":", "_CompressFolderFailed.comment": "An example of {path} is /foo/bar.", + "ControlAndManifestFilesPresent": "Both a manifest file and a CONTROL file exist in port directory: {path}", + "_ControlAndManifestFilesPresent.comment": "An example of {path} is /foo/bar.", "CouldNotDeduceNugetIdAndVersion": "Could not deduce nuget id and version from filename: {path}", "_CouldNotDeduceNugetIdAndVersion.comment": "An example of {path} is /foo/bar.", "CreatedNuGetPackage": "Created nupkg: \"{path}\"", @@ -203,25 +205,25 @@ "_FailedToExtract.comment": "An example of {path} is /foo/bar.", "FailedToFormatMissingFile": "No files to format.\nPlease pass either --all, or the explicit files to format or convert.", "FailedToParseCMakeConsoleOut": "Failed to parse CMake console output to locate block start/end markers.", - "FailedToParseControl": "Failed to parse control file: \"{path}\"", + "FailedToParseControl": "Failed to parse control file: {path}", "_FailedToParseControl.comment": "An example of {path} is /foo/bar.", "FailedToParseJson": "Failed to parse JSON file {path}", "_FailedToParseJson.comment": "An example of {path} is /foo/bar.", - "FailedToParseManifest": "Failed to parse manifest file: \"{path}\"", + "FailedToParseManifest": "Failed to parse manifest file: {path}", "_FailedToParseManifest.comment": "An example of {path} is /foo/bar.", "FailedToProvisionCe": "Failed to provision vcpkg-ce.", "FailedToRead": "Failed to read {path}: {error_msg}", "_FailedToRead.comment": "An example of {path} is /foo/bar. An example of {error_msg} is File Not Found.", - "FailedToReadParagraph": "Failed to read paragraphs from \"{path}\"", + "FailedToReadParagraph": "Failed to read paragraphs from {path}", "_FailedToReadParagraph.comment": "An example of {path} is /foo/bar.", - "FailedToRemoveControl": "Failed to remove control file \"{path}\"", + "FailedToRemoveControl": "Failed to remove control file {path}", "_FailedToRemoveControl.comment": "An example of {path} is /foo/bar.", "FailedToRunToolToDetermineVersion": "Failed to run \"{path}\" to determine the {tool_name} version.", "_FailedToRunToolToDetermineVersion.comment": "Additional information, such as the command line output, if any, will be appended on the line after this message An example of {tool_name} is aria2. An example of {path} is /foo/bar.", "FailedToStoreBackToMirror": "failed to store back to mirror:", "FailedToStoreBinaryCache": "Failed to store binary cache {path}", "_FailedToStoreBinaryCache.comment": "An example of {path} is /foo/bar.", - "FailedToWriteManifest": "Failed to write manifest file \"{path}\"", + "FailedToWriteManifest": "Failed to write manifest file {path}", "_FailedToWriteManifest.comment": "An example of {path} is /foo/bar.", "FailedVendorAuthentication": "One or more {vendor} credential providers failed to authenticate. See '{url}' for more details on how to provide credentials.", "_FailedVendorAuthentication.comment": "An example of {vendor} is Azure. An example of {url} is https://github.com/microsoft/vcpkg.", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 65ea32a43e..badaf7da53 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -678,4 +678,5 @@ namespace vcpkg REGISTER_MESSAGE(FailedToWriteManifest); REGISTER_MESSAGE(FailedToParseControl); REGISTER_MESSAGE(FailedToFormatMissingFile); + REGISTER_MESSAGE(ControlAndManifestFilesPresent); } diff --git a/src/vcpkg/commands.format-manifest.cpp b/src/vcpkg/commands.format-manifest.cpp index 8648af4075..a1cfb2bbbb 100644 --- a/src/vcpkg/commands.format-manifest.cpp +++ b/src/vcpkg/commands.format-manifest.cpp @@ -248,10 +248,10 @@ namespace vcpkg::Commands::FormatManifest auto manifest_exists = fs.exists(manifest_path, IgnoreErrors{}); auto control_exists = fs.exists(control_path, IgnoreErrors{}); - Checks::check_exit(VCPKG_LINE_INFO, - !manifest_exists || !control_exists, - "Both a manifest file and a CONTROL file exist in port directory: %s", - dir); + Checks::msg_check_exit(VCPKG_LINE_INFO, + !manifest_exists || !control_exists, + msgControlAndManifestFilesPresent, + msg::path = dir); if (manifest_exists) { From ddd2308c50df8550e5328cc5d82f75c713759a3b Mon Sep 17 00:00:00 2001 From: Javier Matos Date: Wed, 20 Jul 2022 12:24:57 -0700 Subject: [PATCH 03/14] ManifestFormatCompleted --- include/vcpkg/base/messages.h | 1 + locales/messages.en.json | 1 + locales/messages.json | 1 + src/vcpkg/base/messages.cpp | 1 + src/vcpkg/commands.format-manifest.cpp | 2 +- 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 0ea7cf0dce..a4dcc24580 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -1300,4 +1300,5 @@ namespace vcpkg (msg::path), "", "Both a manifest file and a CONTROL file exist in port directory: {path}"); + DECLARE_MESSAGE(ManifestFormatCompleted, (), "", "Succeeded in formatting the manifest files."); } diff --git a/locales/messages.en.json b/locales/messages.en.json index 47984768af..3d19cb7b66 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -194,6 +194,7 @@ "LoadingOverlayTriplet": "-- [OVERLAY] Loading triplet configuration from: {path}", "LocalizedMessageMustNotContainIndents": "The message named {value} contains what appears to be indenting which must be changed to use LocalizedString::append_indent instead.", "LocalizedMessageMustNotEndWithNewline": "The message named {value} ends with a newline which should be added by formatting rather than by localization.", + "ManifestFormatCompleted": "Succeeded in formatting the manifest files.", "Missing7zHeader": "Unable to find 7z header.", "MissingArgFormatManifest": "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: we will automatically convert all control files passed explicitly.", "MissingExtension": "Missing '{extension}' extension.", diff --git a/locales/messages.json b/locales/messages.json index 5a5cb2b8f3..8c1a771285 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -339,6 +339,7 @@ "_LocalizedMessageMustNotContainIndents.comment": "{value} is is a localized message name like LocalizedMessageMustNotContainIndents. The 'LocalizedString::append_indent' part is locale-invariant.", "LocalizedMessageMustNotEndWithNewline": "The message named {value} ends with a newline which should be added by formatting rather than by localization.", "_LocalizedMessageMustNotEndWithNewline.comment": "{value} is a localized message name like LocalizedMessageMustNotEndWithNewline", + "ManifestFormatCompleted": "Succeeded in formatting the manifest files.", "Missing7zHeader": "Unable to find 7z header.", "MissingArgFormatManifest": "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: we will automatically convert all control files passed explicitly.", "MissingExtension": "Missing '{extension}' extension.", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index badaf7da53..77fc3b985f 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -679,4 +679,5 @@ namespace vcpkg REGISTER_MESSAGE(FailedToParseControl); REGISTER_MESSAGE(FailedToFormatMissingFile); REGISTER_MESSAGE(ControlAndManifestFilesPresent); + REGISTER_MESSAGE(ManifestFormatCompleted); } diff --git a/src/vcpkg/commands.format-manifest.cpp b/src/vcpkg/commands.format-manifest.cpp index a1cfb2bbbb..7d37ee15f0 100644 --- a/src/vcpkg/commands.format-manifest.cpp +++ b/src/vcpkg/commands.format-manifest.cpp @@ -275,7 +275,7 @@ namespace vcpkg::Commands::FormatManifest } else { - print2("Succeeded in formatting the manifest files.\n"); + msg::println(msgManifestFormatCompleted); Checks::exit_success(VCPKG_LINE_INFO); } } From 063587748ad21cf1e6ad6205382fa7226f1dfad5 Mon Sep 17 00:00:00 2001 From: Javier Matos Date: Wed, 20 Jul 2022 12:31:08 -0700 Subject: [PATCH 04/14] replace deprecated call to print2 --- src/vcpkg/commands.find.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/vcpkg/commands.find.cpp b/src/vcpkg/commands.find.cpp index 0a381a176b..0633cd43e9 100644 --- a/src/vcpkg/commands.find.cpp +++ b/src/vcpkg/commands.find.cpp @@ -34,8 +34,7 @@ namespace desc.push_back(Json::Value::string(line)); } } - - print2(Json::stringify(obj)); + msg::write_unlocalized_text_to_stdout(Color::none, Json::stringify(obj)); } constexpr const int s_name_and_ver_columns = 41; void do_print(const SourceParagraph& source_paragraph, bool full_desc) From 968d6e1993179afd664387d5a70332a315458db5 Mon Sep 17 00:00:00 2001 From: Javier Matos Date: Wed, 20 Jul 2022 13:09:29 -0700 Subject: [PATCH 05/14] Replacing printf with msg::write_unlocalized_text_to_stdout --- include/vcpkg/base/messages.h | 7 +++++- locales/messages.en.json | 2 ++ locales/messages.json | 2 ++ src/vcpkg/base/messages.cpp | 2 ++ src/vcpkg/commands.find.cpp | 41 +++++++++++++++++++++-------------- 5 files changed, 37 insertions(+), 17 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index a4dcc24580..1ecc3ba47c 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -1301,4 +1301,9 @@ namespace vcpkg "", "Both a manifest file and a CONTROL file exist in port directory: {path}"); DECLARE_MESSAGE(ManifestFormatCompleted, (), "", "Succeeded in formatting the manifest files."); -} + DECLARE_MESSAGE(SuggestGitPull, (), "", "The result may be outdated. Run `git pull` to get the latest results."); + DECLARE_MESSAGE(MissingPortSuggestPullRequest, + (), + "", + "If your port is not listed, please open an issue at and/or consider making a pull request."); +} \ No newline at end of file diff --git a/locales/messages.en.json b/locales/messages.en.json index 3d19cb7b66..11435f2240 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -198,6 +198,7 @@ "Missing7zHeader": "Unable to find 7z header.", "MissingArgFormatManifest": "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: we will automatically convert all control files passed explicitly.", "MissingExtension": "Missing '{extension}' extension.", + "MissingPortSuggestPullRequest": "If your port is not listed, please open an issue at and/or consider making a pull request.", "MonoInstructions": "This may be caused by an incomplete mono installation. Full mono is available on some systems via `sudo apt install mono-complete`. Ubuntu 18.04 users may need a newer version of mono, available at https://www.mono-project.com/download/stable/", "MsiexecFailedToExtract": "msiexec failed while extracting \"{path}\" with launch or exit code {exit_code} and message:", "NewConfigurationAlreadyExists": "Creating a manifest would overwrite a vcpkg-configuration.json at {path}.", @@ -233,6 +234,7 @@ "SettingEnvVar": "-- Setting \"{env_var}\" environment variables to \"{url}\".", "SourceFieldPortNameMismatch": "The 'Source' field inside the CONTROL file, or \"name\" field inside the vcpkg.json file has the name {package_name} and does not match the port directory \"{path}\".", "StoredBinaryCache": "Stored binary cache: \"{path}\"", + "SuggestGitPull": "The result may be outdated. Run `git pull` to get the latest results.", "SuggestStartingBashShell": "Please make sure you have started a new bash shell for the change to take effect.", "SystemApiErrorMessage": "calling {system_api} failed with {exit_code} ({error_msg})", "ToolFetchFailed": "Could not fetch {tool_name}.", diff --git a/locales/messages.json b/locales/messages.json index 8c1a771285..c0daf292ca 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -344,6 +344,7 @@ "MissingArgFormatManifest": "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: we will automatically convert all control files passed explicitly.", "MissingExtension": "Missing '{extension}' extension.", "_MissingExtension.comment": "An example of {extension} is .exe.", + "MissingPortSuggestPullRequest": "If your port is not listed, please open an issue at and/or consider making a pull request.", "MonoInstructions": "This may be caused by an incomplete mono installation. Full mono is available on some systems via `sudo apt install mono-complete`. Ubuntu 18.04 users may need a newer version of mono, available at https://www.mono-project.com/download/stable/", "MsiexecFailedToExtract": "msiexec failed while extracting \"{path}\" with launch or exit code {exit_code} and message:", "_MsiexecFailedToExtract.comment": "An example of {path} is /foo/bar. An example of {exit_code} is 127.", @@ -402,6 +403,7 @@ "_SourceFieldPortNameMismatch.comment": "{package_name} and \"{path}\" are both names of installable ports/packages. 'Source', 'CONTROL', 'vcpkg.json', and 'name' references are locale-invariant. An example of {package_name} is zlib. An example of {path} is /foo/bar.", "StoredBinaryCache": "Stored binary cache: \"{path}\"", "_StoredBinaryCache.comment": "An example of {path} is /foo/bar.", + "SuggestGitPull": "The result may be outdated. Run `git pull` to get the latest results.", "SuggestStartingBashShell": "Please make sure you have started a new bash shell for the change to take effect.", "SystemApiErrorMessage": "calling {system_api} failed with {exit_code} ({error_msg})", "_SystemApiErrorMessage.comment": "An example of {system_api} is CreateProcessW. An example of {exit_code} is 127. An example of {error_msg} is File Not Found.", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 77fc3b985f..1bd11ec3c4 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -680,4 +680,6 @@ namespace vcpkg REGISTER_MESSAGE(FailedToFormatMissingFile); REGISTER_MESSAGE(ControlAndManifestFilesPresent); REGISTER_MESSAGE(ManifestFormatCompleted); + REGISTER_MESSAGE(SuggestGitPull); + REGISTER_MESSAGE(MissingPortSuggestPullRequest); } diff --git a/src/vcpkg/commands.find.cpp b/src/vcpkg/commands.find.cpp index 0633cd43e9..1726cd59f1 100644 --- a/src/vcpkg/commands.find.cpp +++ b/src/vcpkg/commands.find.cpp @@ -42,10 +42,11 @@ namespace auto full_version = Version(source_paragraph.raw_version, source_paragraph.port_version).to_string(); if (full_desc) { - vcpkg::printf("%-20s %-16s %s\n", - source_paragraph.name, - full_version, - Strings::join("\n ", source_paragraph.description)); + msg::write_unlocalized_text_to_stdout(Color::none, + fmt::format("%-20s %-16s %s\n", + source_paragraph.name, + full_version, + Strings::join("\n ", source_paragraph.description))); } else { @@ -60,12 +61,13 @@ namespace used_columns += std::max(full_version.size(), ver_size) + 1; size_t description_size = used_columns < (119 - 40) ? 119 - used_columns : 40; - vcpkg::printf("%-*s %-*s %s\n", - name_columns, - source_paragraph.name, - ver_size, - full_version, - vcpkg::shorten_text(description, description_size)); + msg::write_unlocalized_text_to_stdout(Color::none, + fmt::format("%-*s %-*s %s\n", + name_columns, + source_paragraph.name, + ver_size, + full_version, + vcpkg::shorten_text(description, description_size))); } } @@ -74,7 +76,9 @@ namespace auto full_feature_name = Strings::concat(name, "[", feature_paragraph.name, "]"); if (full_desc) { - vcpkg::printf("%-37s %s\n", full_feature_name, Strings::join("\n ", feature_paragraph.description)); + msg::write_unlocalized_text_to_stdout( + Color::none, + fmt::format("%-37s %s\n", full_feature_name, Strings::join("\n ", feature_paragraph.description))); } else { @@ -85,8 +89,11 @@ namespace } size_t desc_length = 119 - std::min(60, 1 + std::max(s_name_and_ver_columns, full_feature_name.size())); - vcpkg::printf( - "%-*s %s\n", s_name_and_ver_columns, full_feature_name, vcpkg::shorten_text(description, desc_length)); + msg::write_unlocalized_text_to_stdout(Color::none, + fmt::format("%-*s %s\n", + s_name_and_ver_columns, + full_feature_name, + vcpkg::shorten_text(description, desc_length))); } } @@ -180,9 +187,11 @@ namespace vcpkg::Commands if (!enable_json) { - print2("The result may be outdated. Run `git pull` to get the latest results.\n" - "\nIf your port is not listed, please open an issue at and/or consider making a pull request:\n" - " https://github.com/Microsoft/vcpkg/issues\n"); + msg::println(msg::format(msgSuggestGitPull) + .append_raw("\n") + .append(msgMissingPortSuggestPullRequest) + .append_indent() + .append_raw("- https://github.com/Microsoft/vcpkg/issues")); } Checks::exit_success(VCPKG_LINE_INFO); From d66a32bf4211648942b5b2d05c569b032f025337 Mon Sep 17 00:00:00 2001 From: Javier Matos Date: Wed, 20 Jul 2022 13:16:54 -0700 Subject: [PATCH 06/14] ArtifactsOptionIncompatibility --- include/vcpkg/base/messages.h | 1 + locales/messages.en.json | 1 + locales/messages.json | 2 ++ src/vcpkg/base/messages.cpp | 1 + src/vcpkg/commands.find.cpp | 4 ++-- 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 37ff70dd71..7ff393fbaf 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -1325,4 +1325,5 @@ namespace vcpkg (), "", "If your port is not listed, please open an issue at and/or consider making a pull request."); + DECLARE_MESSAGE(ArtifactsOptionIncompatibility, (msg::option), "", "--{option} has no effect on find artifact."); } \ No newline at end of file diff --git a/locales/messages.en.json b/locales/messages.en.json index b3b5f23748..806bcead59 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -37,6 +37,7 @@ "AlreadyInstalledNotHead": "{spec} is already installed -- not building from HEAD", "AnotherInstallationInProgress": "Another installation is in progress on the machine, sleeping 6s before retrying.", "AppliedUserIntegration": "Applied user-wide integration for this vcpkg root.", + "ArtifactsOptionIncompatibility": "--{option} has no effect on find artifact.", "AttemptingToFetchPackagesFromVendor": "Attempting to fetch {count} package(s) from {vendor}", "AuthenticationMayRequireManualAction": "One or more {vendor} credential providers requested manual action. Add the binary source 'interactive' to allow interactivity.", "AutoSettingEnvVar": "-- Automatically setting {env_var} environment variables to \"{url}\".", diff --git a/locales/messages.json b/locales/messages.json index 725454a5f7..c193c35ac1 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -66,6 +66,8 @@ "_AlreadyInstalledNotHead.comment": "'HEAD' means the most recent version of source code An example of {spec} is zlib:x64-windows.", "AnotherInstallationInProgress": "Another installation is in progress on the machine, sleeping 6s before retrying.", "AppliedUserIntegration": "Applied user-wide integration for this vcpkg root.", + "ArtifactsOptionIncompatibility": "--{option} has no effect on find artifact.", + "_ArtifactsOptionIncompatibility.comment": "An example of {option} is editable.", "AttemptingToFetchPackagesFromVendor": "Attempting to fetch {count} package(s) from {vendor}", "_AttemptingToFetchPackagesFromVendor.comment": "An example of {count} is 42. An example of {vendor} is Azure.", "AuthenticationMayRequireManualAction": "One or more {vendor} credential providers requested manual action. Add the binary source 'interactive' to allow interactivity.", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 46ebd7e2b2..70d49956d3 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -692,4 +692,5 @@ namespace vcpkg REGISTER_MESSAGE(ManifestFormatCompleted); REGISTER_MESSAGE(SuggestGitPull); REGISTER_MESSAGE(MissingPortSuggestPullRequest); + REGISTER_MESSAGE(ArtifactsOptionIncompatibility); } diff --git a/src/vcpkg/commands.find.cpp b/src/vcpkg/commands.find.cpp index 1726cd59f1..a0202601ba 100644 --- a/src/vcpkg/commands.find.cpp +++ b/src/vcpkg/commands.find.cpp @@ -225,12 +225,12 @@ namespace vcpkg::Commands { if (full_description) { - print2(Color::warning, "--%s has no effect on find artifact\n", OPTION_FULLDESC); + msg::println_warning(msgArtifactsOptionIncompatibility, msg::option = OPTION_FULLDESC); } if (enable_json) { - print2(Color::warning, "--x-json has no effect on find artifact\n"); + msg::println_warning(msgArtifactsOptionIncompatibility, msg::option = "x-json"); } Optional filter_hash = filter.map(Hash::get_string_sha256); From 0856fd31ad38582e257aa317553e2b0bea2da994 Mon Sep 17 00:00:00 2001 From: Javier Matos Date: Wed, 20 Jul 2022 13:21:00 -0700 Subject: [PATCH 07/14] AddCommandFirstArg --- include/vcpkg/base/messages.h | 1 + locales/messages.en.json | 1 + locales/messages.json | 1 + src/vcpkg/base/messages.cpp | 1 + src/vcpkg/commands.find.cpp | 2 +- 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 7ff393fbaf..f3b2568b93 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -1326,4 +1326,5 @@ namespace vcpkg "", "If your port is not listed, please open an issue at and/or consider making a pull request."); DECLARE_MESSAGE(ArtifactsOptionIncompatibility, (msg::option), "", "--{option} has no effect on find artifact."); + DECLARE_MESSAGE(AddCommandFirstArg, (), "", "The first parameter to add must be 'artifact' or 'port'."); } \ No newline at end of file diff --git a/locales/messages.en.json b/locales/messages.en.json index 806bcead59..7f2d85cd2c 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -1,5 +1,6 @@ { "AddArtifactOnlyOne": "'{command_line}' can only add one artifact at a time.", + "AddCommandFirstArg": "The first parameter to add must be 'artifact' or 'port'.", "AddFirstArgument": "The first argument to '{command_line}' must be 'artifact' or 'port'.", "AddPortRequiresManifest": "'{command_line}' requires an active manifest file.", "AddPortSucceeded": "Succeeded in adding ports to vcpkg.json file.", diff --git a/locales/messages.json b/locales/messages.json index c193c35ac1..b0d2138a36 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -1,6 +1,7 @@ { "AddArtifactOnlyOne": "'{command_line}' can only add one artifact at a time.", "_AddArtifactOnlyOne.comment": "An example of {command_line} is vcpkg install zlib.", + "AddCommandFirstArg": "The first parameter to add must be 'artifact' or 'port'.", "AddFirstArgument": "The first argument to '{command_line}' must be 'artifact' or 'port'.", "_AddFirstArgument.comment": "An example of {command_line} is vcpkg install zlib.", "AddPortRequiresManifest": "'{command_line}' requires an active manifest file.", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 70d49956d3..2bf0c4ac51 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -693,4 +693,5 @@ namespace vcpkg REGISTER_MESSAGE(SuggestGitPull); REGISTER_MESSAGE(MissingPortSuggestPullRequest); REGISTER_MESSAGE(ArtifactsOptionIncompatibility); + REGISTER_MESSAGE(AddCommandFirstArg); } diff --git a/src/vcpkg/commands.find.cpp b/src/vcpkg/commands.find.cpp index a0202601ba..a1216b1e93 100644 --- a/src/vcpkg/commands.find.cpp +++ b/src/vcpkg/commands.find.cpp @@ -262,6 +262,6 @@ namespace vcpkg::Commands perform_find_port_and_exit(paths, full_description, enable_json, filter, args.overlay_ports); } - Checks::exit_with_message(VCPKG_LINE_INFO, "The first parmaeter to add must be 'artifact' or 'port'.\n"); + Checks::msg_exit_with_message(VCPKG_LINE_INFO, msgAddCommandFirstArg); } } From fc6b49a2264ae41c6cb1b95eda63eb30ad144513 Mon Sep 17 00:00:00 2001 From: Javier Matos Date: Wed, 20 Jul 2022 13:25:34 -0700 Subject: [PATCH 08/14] FailedToObtainLocalPortGitSha --- include/vcpkg/base/messages.h | 1 + locales/messages.en.json | 1 + locales/messages.json | 1 + src/vcpkg/base/messages.cpp | 1 + src/vcpkg/commands.civerifyversions.cpp | 6 +++--- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index f3b2568b93..5304cf002f 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -1327,4 +1327,5 @@ namespace vcpkg "If your port is not listed, please open an issue at and/or consider making a pull request."); DECLARE_MESSAGE(ArtifactsOptionIncompatibility, (msg::option), "", "--{option} has no effect on find artifact."); DECLARE_MESSAGE(AddCommandFirstArg, (), "", "The first parameter to add must be 'artifact' or 'port'."); + DECLARE_MESSAGE(FailedToObtainLocalPortGitSha, (), "", "Failed to obtain git SHAs for local ports."); } \ No newline at end of file diff --git a/locales/messages.en.json b/locales/messages.en.json index 7f2d85cd2c..005ccb08ba 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -119,6 +119,7 @@ "ExtendedDocumenationAtUrl": "Extended documentation available at '{url}'.", "FailedToExtract": "Failed to extract \"{path}\":", "FailedToFormatMissingFile": "No files to format.\nPlease pass either --all, or the explicit files to format or convert.", + "FailedToObtainLocalPortGitSha": "Failed to obtain git SHAs for local ports.", "FailedToParseCMakeConsoleOut": "Failed to parse CMake console output to locate block start/end markers.", "FailedToParseControl": "Failed to parse control file: {path}", "FailedToParseJson": "Failed to parse JSON file {path}", diff --git a/locales/messages.json b/locales/messages.json index b0d2138a36..d5e86ca986 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -211,6 +211,7 @@ "FailedToExtract": "Failed to extract \"{path}\":", "_FailedToExtract.comment": "An example of {path} is /foo/bar.", "FailedToFormatMissingFile": "No files to format.\nPlease pass either --all, or the explicit files to format or convert.", + "FailedToObtainLocalPortGitSha": "Failed to obtain git SHAs for local ports.", "FailedToParseCMakeConsoleOut": "Failed to parse CMake console output to locate block start/end markers.", "FailedToParseControl": "Failed to parse control file: {path}", "_FailedToParseControl.comment": "An example of {path} is /foo/bar.", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 2bf0c4ac51..e0e659296a 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -694,4 +694,5 @@ namespace vcpkg REGISTER_MESSAGE(MissingPortSuggestPullRequest); REGISTER_MESSAGE(ArtifactsOptionIncompatibility); REGISTER_MESSAGE(AddCommandFirstArg); + REGISTER_MESSAGE(FailedToObtainLocalPortGitSha); } diff --git a/src/vcpkg/commands.civerifyversions.cpp b/src/vcpkg/commands.civerifyversions.cpp index 9a92f3697d..1bd921e79d 100644 --- a/src/vcpkg/commands.civerifyversions.cpp +++ b/src/vcpkg/commands.civerifyversions.cpp @@ -297,9 +297,9 @@ namespace vcpkg::Commands::CIVerifyVersions auto maybe_port_git_tree_map = paths.git_get_local_port_treeish_map(); if (!maybe_port_git_tree_map) { - Checks::exit_with_message(VCPKG_LINE_INFO, - "Fatal error: Failed to obtain git SHAs for local ports.\n%s", - maybe_port_git_tree_map.error()); + Checks::msg_exit_with_message( + VCPKG_LINE_INFO, + msg::format(msgFailedToObtainLocalPortGitSha).append_raw("\n" + maybe_port_git_tree_map.error())); } auto port_git_tree_map = maybe_port_git_tree_map.value_or_exit(VCPKG_LINE_INFO); From 88c66171c10feff21c83fa9ae1a51f5a0186419f Mon Sep 17 00:00:00 2001 From: Javier Matos Date: Wed, 20 Jul 2022 13:29:02 -0700 Subject: [PATCH 09/14] replace printf statements --- src/vcpkg/commands.civerifyversions.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/vcpkg/commands.civerifyversions.cpp b/src/vcpkg/commands.civerifyversions.cpp index 1bd921e79d..54fc339c99 100644 --- a/src/vcpkg/commands.civerifyversions.cpp +++ b/src/vcpkg/commands.civerifyversions.cpp @@ -313,13 +313,13 @@ namespace vcpkg::Commands::CIVerifyVersions auto port_name = port_path.stem(); if (Util::Sets::contains(exclusion_set, port_name.to_string())) { - if (verbose) vcpkg::printf("SKIP: %s\n", port_name); + if (verbose) msg::write_unlocalized_text_to_stdout(Color::error, fmt::format("SKIP: %s\n", port_name)); continue; } auto git_tree_it = port_git_tree_map.find(port_name); if (git_tree_it == port_git_tree_map.end()) { - vcpkg::printf(Color::error, "FAIL: %s\n", port_name); + msg::write_unlocalized_text_to_stdout(Color::error, fmt::format("FAIL: %s\n", port_name)); errors.emplace(Strings::format("Error: While validating port %s.\n" " Missing Git SHA.\n" " Run:\n\n" @@ -344,7 +344,7 @@ namespace vcpkg::Commands::CIVerifyVersions if (manifest_exists && control_exists) { - vcpkg::printf(Color::error, "FAIL: %s\n", port_name); + msg::write_unlocalized_text_to_stdout(Color::error, fmt::format("FAIL: %s\n", port_name)); errors.emplace( Strings::format("Error: While validating port %s.\n" " Both a manifest file and a CONTROL file exist in port directory: %s", @@ -355,7 +355,7 @@ namespace vcpkg::Commands::CIVerifyVersions if (!manifest_exists && !control_exists) { - vcpkg::printf(Color::error, "FAIL: %s\n", port_name); + msg::write_unlocalized_text_to_stdout(Color::error, fmt::format("FAIL: %s\n", port_name)); errors.emplace(Strings::format("Error: While validating port %s.\n" " No manifest file or CONTROL file exist in port directory: %s", port_name, @@ -367,7 +367,7 @@ namespace vcpkg::Commands::CIVerifyVersions auto versions_file_path = paths.builtin_registry_versions / prefix / Strings::concat(port_name, ".json"); if (!fs.exists(versions_file_path, IgnoreErrors{})) { - vcpkg::printf(Color::error, "FAIL: %s\n", port_name); + msg::write_unlocalized_text_to_stdout(Color::error, fmt::format("FAIL: %s\n", port_name)); errors.emplace(Strings::format("Error: While validating port %s.\n" " Missing expected versions file at: %s\n" " Run:\n\n" @@ -384,7 +384,7 @@ namespace vcpkg::Commands::CIVerifyVersions if (!maybe_ok) { - vcpkg::printf(Color::error, "FAIL: %s\n", port_name); + msg::write_unlocalized_text_to_stdout(Color::error, fmt::format("FAIL: %s\n", port_name)); errors.emplace(maybe_ok.error()); continue; } From a0f738917df2e880d3d729fb6d60713ed343e523 Mon Sep 17 00:00:00 2001 From: Javier Matos Date: Wed, 20 Jul 2022 13:47:00 -0700 Subject: [PATCH 10/14] [Add Function] LocalizedString& append_nl() ErrorsFound SuggestResolution --- include/vcpkg/base/messages.h | 11 +++++++++++ src/vcpkg/base/messages.cpp | 2 ++ src/vcpkg/commands.civerifyversions.cpp | 16 ++++++++++------ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 5304cf002f..44e6f89a6f 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -74,6 +74,12 @@ namespace vcpkg return *this; } + LocalizedString& append_nl() + { + m_data.append("\n"); + return *this; + } + friend const char* to_printf_arg(const LocalizedString& s) { return s.data().c_str(); } friend bool operator==(const LocalizedString& lhs, const LocalizedString& rhs) @@ -1328,4 +1334,9 @@ namespace vcpkg DECLARE_MESSAGE(ArtifactsOptionIncompatibility, (msg::option), "", "--{option} has no effect on find artifact."); DECLARE_MESSAGE(AddCommandFirstArg, (), "", "The first parameter to add must be 'artifact' or 'port'."); DECLARE_MESSAGE(FailedToObtainLocalPortGitSha, (), "", "Failed to obtain git SHAs for local ports."); + DECLARE_MESSAGE(ErrorsFound, (), "", "Found the following errors:"); + DECLARE_MESSAGE(SuggestResolution, + (msg::command_name, msg::option), + "", + "To attempt to resolve all errors at once, run:\nvcpkg {command_name} --{option}"); } \ No newline at end of file diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index e0e659296a..8a4eaffd71 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -695,4 +695,6 @@ namespace vcpkg REGISTER_MESSAGE(ArtifactsOptionIncompatibility); REGISTER_MESSAGE(AddCommandFirstArg); REGISTER_MESSAGE(FailedToObtainLocalPortGitSha); + REGISTER_MESSAGE(ErrorsFound); + REGISTER_MESSAGE(SuggestResolution); } diff --git a/src/vcpkg/commands.civerifyversions.cpp b/src/vcpkg/commands.civerifyversions.cpp index 54fc339c99..5c71d0290b 100644 --- a/src/vcpkg/commands.civerifyversions.cpp +++ b/src/vcpkg/commands.civerifyversions.cpp @@ -389,19 +389,23 @@ namespace vcpkg::Commands::CIVerifyVersions continue; } - if (verbose) vcpkg::printf("%s", maybe_ok.value_or_exit(VCPKG_LINE_INFO)); + if (verbose) + msg::write_unlocalized_text_to_stdout(Color::none, + fmt::format("%s", maybe_ok.value_or_exit(VCPKG_LINE_INFO))); } if (!errors.empty()) { - print2(Color::error, "Found the following errors:\n"); + auto message = msg::format(msgErrorsFound); for (auto&& error : errors) { - vcpkg::printf(Color::error, "%s\n", error); + message.append_nl().append_indent().append_raw(error); } - print2(Color::error, - "\nTo attempt to resolve all errors at once, run:\n\n" - " vcpkg x-add-version --all\n\n"); + + message.append_nl().append(msgSuggestResolution, msg::command_name = "x-add-version", msg::option = "all"); + + msg::println_error(message); + Checks::exit_fail(VCPKG_LINE_INFO); } Checks::exit_success(VCPKG_LINE_INFO); From a8b3fe682fde510fb4ba833e0e8cf0f1bafcc59b Mon Sep 17 00:00:00 2001 From: Javier Matos Date: Wed, 20 Jul 2022 13:50:22 -0700 Subject: [PATCH 11/14] Replaced calls to append_raw("\n") with append_nl() --- locales/messages.en.json | 2 ++ locales/messages.json | 3 +++ src/vcpkg/base/messages.cpp | 36 ++++++++++++++++++------------------ src/vcpkg/commands.find.cpp | 2 +- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/locales/messages.en.json b/locales/messages.en.json index 005ccb08ba..956c4f31f3 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -111,6 +111,7 @@ "ErrorVcvarsUnsupported": "in triplet {triplet}: Use of Visual Studio's Developer Prompt is unsupported on non-Windows hosts.\nDefine 'VCPKG_CMAKE_SYSTEM_NAME' or 'VCPKG_CHAINLOAD_TOOLCHAIN_FILE' in the triplet file.", "ErrorVsCodeNotFound": "Visual Studio Code was not found and the environment variable {env_var} is not set or invalid.", "ErrorVsCodeNotFoundPathExamined": "The following paths were examined:", + "ErrorsFound": "Found the following errors:", "ExcludedPackage": "Excluded {spec}", "ExpectedCharacterHere": "expected '{expected}' here", "ExpectedFailOrSkip": "expected 'fail', 'skip', or 'pass' here", @@ -245,6 +246,7 @@ "SourceFieldPortNameMismatch": "The 'Source' field inside the CONTROL file, or \"name\" field inside the vcpkg.json file has the name {package_name} and does not match the port directory \"{path}\".", "StoredBinaryCache": "Stored binary cache: \"{path}\"", "SuggestGitPull": "The result may be outdated. Run `git pull` to get the latest results.", + "SuggestResolution": "To attempt to resolve all errors at once, run:\nvcpkg {command_name} --{option}", "SuggestStartingBashShell": "Please make sure you have started a new bash shell for the change to take effect.", "SupportedPort": "Port {package_name} is supported.", "SystemApiErrorMessage": "calling {system_api} failed with {exit_code} ({error_msg})", diff --git a/locales/messages.json b/locales/messages.json index d5e86ca986..037c7f6c3f 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -199,6 +199,7 @@ "ErrorVsCodeNotFound": "Visual Studio Code was not found and the environment variable {env_var} is not set or invalid.", "_ErrorVsCodeNotFound.comment": "An example of {env_var} is VCPKG_DEFAULT_TRIPLET.", "ErrorVsCodeNotFoundPathExamined": "The following paths were examined:", + "ErrorsFound": "Found the following errors:", "ExcludedPackage": "Excluded {spec}", "_ExcludedPackage.comment": "An example of {spec} is zlib:x64-windows.", "ExpectedCharacterHere": "expected '{expected}' here", @@ -420,6 +421,8 @@ "StoredBinaryCache": "Stored binary cache: \"{path}\"", "_StoredBinaryCache.comment": "An example of {path} is /foo/bar.", "SuggestGitPull": "The result may be outdated. Run `git pull` to get the latest results.", + "SuggestResolution": "To attempt to resolve all errors at once, run:\nvcpkg {command_name} --{option}", + "_SuggestResolution.comment": "An example of {command_name} is install. An example of {option} is editable.", "SuggestStartingBashShell": "Please make sure you have started a new bash shell for the change to take effect.", "SupportedPort": "Port {package_name} is supported.", "_SupportedPort.comment": "An example of {package_name} is zlib.", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 8a4eaffd71..1040cc7ad4 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -406,6 +406,7 @@ namespace vcpkg MessageSink& stderr_sink = stderr_sink_instance; REGISTER_MESSAGE(AddArtifactOnlyOne); + REGISTER_MESSAGE(AddCommandFirstArg); REGISTER_MESSAGE(AddFirstArgument); REGISTER_MESSAGE(AddingCompletionEntry); REGISTER_MESSAGE(AddPortRequiresManifest); @@ -443,6 +444,7 @@ namespace vcpkg REGISTER_MESSAGE(AlreadyInstalledNotHead); REGISTER_MESSAGE(AnotherInstallationInProgress); REGISTER_MESSAGE(AppliedUserIntegration); + REGISTER_MESSAGE(ArtifactsOptionIncompatibility); REGISTER_MESSAGE(AttemptingToFetchPackagesFromVendor); REGISTER_MESSAGE(AuthenticationMayRequireManualAction); REGISTER_MESSAGE(AutomaticLinkingForMSBuildProjects); @@ -482,6 +484,7 @@ namespace vcpkg REGISTER_MESSAGE(CMakeToolChainFile); REGISTER_MESSAGE(CommandFailed); REGISTER_MESSAGE(CompressFolderFailed); + REGISTER_MESSAGE(ControlAndManifestFilesPresent); REGISTER_MESSAGE(CouldNotDeduceNugetIdAndVersion); REGISTER_MESSAGE(CreatedNuGetPackage); REGISTER_MESSAGE(CurlReportedUnexpectedResults); @@ -507,6 +510,7 @@ namespace vcpkg REGISTER_MESSAGE(ErrorNoVSInstanceVersion); REGISTER_MESSAGE(ErrorRequireBaseline); REGISTER_MESSAGE(ErrorRequirePackagesList); + REGISTER_MESSAGE(ErrorsFound); REGISTER_MESSAGE(ErrorUnableToDetectCompilerInfo); REGISTER_MESSAGE(ErrorVcvarsUnsupported); REGISTER_MESSAGE(ErrorVsCodeNotFound); @@ -518,11 +522,20 @@ namespace vcpkg REGISTER_MESSAGE(ExpectedTripletName); REGISTER_MESSAGE(ExtendedDocumenationAtUrl); REGISTER_MESSAGE(FailedToExtract); + REGISTER_MESSAGE(FailedToFormatMissingFile); + REGISTER_MESSAGE(FailedToObtainLocalPortGitSha); REGISTER_MESSAGE(FailedToParseCMakeConsoleOut); + REGISTER_MESSAGE(FailedToParseControl); + REGISTER_MESSAGE(FailedToParseJson); + REGISTER_MESSAGE(FailedToParseManifest); REGISTER_MESSAGE(FailedToProvisionCe); + REGISTER_MESSAGE(FailedToRead); + REGISTER_MESSAGE(FailedToReadParagraph); + REGISTER_MESSAGE(FailedToRemoveControl); REGISTER_MESSAGE(FailedToRunToolToDetermineVersion); REGISTER_MESSAGE(FailedToStoreBackToMirror); REGISTER_MESSAGE(FailedToStoreBinaryCache); + REGISTER_MESSAGE(FailedToWriteManifest); REGISTER_MESSAGE(FailedVendorAuthentication); REGISTER_MESSAGE(FeedbackAppreciated); REGISTER_MESSAGE(FishCompletion); @@ -564,8 +577,6 @@ namespace vcpkg REGISTER_MESSAGE(InvalidArgumentRequiresTwoOrThreeArguments); REGISTER_MESSAGE(InvalidArgumentRequiresValidToken); REGISTER_MESSAGE(InvalidFormatString); - REGISTER_MESSAGE(FailedToParseJson); - REGISTER_MESSAGE(FailedToRead); REGISTER_MESSAGE(JsonErrorMustBeAnObject); REGISTER_MESSAGE(LaunchingProgramFailed); REGISTER_MESSAGE(LicenseExpressionContainsExtraPlus); @@ -590,8 +601,11 @@ namespace vcpkg REGISTER_MESSAGE(LoadingOverlayTriplet); REGISTER_MESSAGE(LocalizedMessageMustNotContainIndents); REGISTER_MESSAGE(LocalizedMessageMustNotEndWithNewline); + REGISTER_MESSAGE(ManifestFormatCompleted); REGISTER_MESSAGE(Missing7zHeader); + REGISTER_MESSAGE(MissingArgFormatManifest); REGISTER_MESSAGE(MissingExtension); + REGISTER_MESSAGE(MissingPortSuggestPullRequest); REGISTER_MESSAGE(MonoInstructions); REGISTER_MESSAGE(MsiexecFailedToExtract); REGISTER_MESSAGE(NavigateToNPS); @@ -628,6 +642,8 @@ namespace vcpkg REGISTER_MESSAGE(SettingEnvVar); REGISTER_MESSAGE(SourceFieldPortNameMismatch); REGISTER_MESSAGE(StoredBinaryCache); + REGISTER_MESSAGE(SuggestGitPull); + REGISTER_MESSAGE(SuggestResolution); REGISTER_MESSAGE(SuggestStartingBashShell); REGISTER_MESSAGE(SupportedPort); REGISTER_MESSAGE(SystemApiErrorMessage); @@ -681,20 +697,4 @@ namespace vcpkg REGISTER_MESSAGE(WaitingToTakeFilesystemLock); REGISTER_MESSAGE(WarningMessageMustUsePrintWarning); REGISTER_MESSAGE(WarningsTreatedAsErrors); - REGISTER_MESSAGE(FailedToParseManifest); - REGISTER_MESSAGE(FailedToReadParagraph); - REGISTER_MESSAGE(MissingArgFormatManifest); - REGISTER_MESSAGE(FailedToRemoveControl); - REGISTER_MESSAGE(FailedToWriteManifest); - REGISTER_MESSAGE(FailedToParseControl); - REGISTER_MESSAGE(FailedToFormatMissingFile); - REGISTER_MESSAGE(ControlAndManifestFilesPresent); - REGISTER_MESSAGE(ManifestFormatCompleted); - REGISTER_MESSAGE(SuggestGitPull); - REGISTER_MESSAGE(MissingPortSuggestPullRequest); - REGISTER_MESSAGE(ArtifactsOptionIncompatibility); - REGISTER_MESSAGE(AddCommandFirstArg); - REGISTER_MESSAGE(FailedToObtainLocalPortGitSha); - REGISTER_MESSAGE(ErrorsFound); - REGISTER_MESSAGE(SuggestResolution); } diff --git a/src/vcpkg/commands.find.cpp b/src/vcpkg/commands.find.cpp index a1216b1e93..31ad257bef 100644 --- a/src/vcpkg/commands.find.cpp +++ b/src/vcpkg/commands.find.cpp @@ -188,7 +188,7 @@ namespace vcpkg::Commands if (!enable_json) { msg::println(msg::format(msgSuggestGitPull) - .append_raw("\n") + .append_nl() .append(msgMissingPortSuggestPullRequest) .append_indent() .append_raw("- https://github.com/Microsoft/vcpkg/issues")); From 7d4cf6a5027251c57667b8349d10c5e3f553cb12 Mon Sep 17 00:00:00 2001 From: Javier Matos Date: Wed, 20 Jul 2022 13:53:08 -0700 Subject: [PATCH 12/14] Sorted messages --- include/vcpkg/base/messages.h | 68 +++++++++++++++++------------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 44e6f89a6f..c54aeaf452 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -413,6 +413,7 @@ namespace vcpkg (msg::command_line), "", "'{command_line}' can only add one artifact at a time."); + DECLARE_MESSAGE(AddCommandFirstArg, (), "", "The first parameter to add must be 'artifact' or 'port'."); DECLARE_MESSAGE(AddFirstArgument, (msg::command_line), "", @@ -506,6 +507,7 @@ namespace vcpkg "", "Another installation is in progress on the machine, sleeping 6s before retrying."); DECLARE_MESSAGE(AppliedUserIntegration, (), "", "Applied user-wide integration for this vcpkg root."); + DECLARE_MESSAGE(ArtifactsOptionIncompatibility, (msg::option), "", "--{option} has no effect on find artifact."); DECLARE_MESSAGE(AttemptingToFetchPackagesFromVendor, (msg::count, msg::vendor), "", @@ -665,6 +667,10 @@ namespace vcpkg "{command_line}\n" "failed with the following results:"); DECLARE_MESSAGE(CompressFolderFailed, (msg::path), "", "Failed to compress folder \"{path}\":"); + DECLARE_MESSAGE(ControlAndManifestFilesPresent, + (msg::path), + "", + "Both a manifest file and a CONTROL file exist in port directory: {path}"); DECLARE_MESSAGE(CouldNotDeduceNugetIdAndVersion, (msg::path), "", @@ -747,6 +753,7 @@ namespace vcpkg (), "", "`vcpkg install` requires a list of packages to install in classic mode."); + DECLARE_MESSAGE(ErrorsFound, (), "", "Found the following errors:"); DECLARE_MESSAGE( ErrorUnableToDetectCompilerInfo, (), @@ -774,11 +781,22 @@ namespace vcpkg DECLARE_MESSAGE(ExpectedTripletName, (), "", "expected a triplet name here"); DECLARE_MESSAGE(ExtendedDocumenationAtUrl, (msg::url), "", "Extended documentation available at '{url}'."); DECLARE_MESSAGE(FailedToExtract, (msg::path), "", "Failed to extract \"{path}\":"); + DECLARE_MESSAGE(FailedToFormatMissingFile, + (), + "", + "No files to format.\nPlease pass either --all, or the explicit files to format or convert."); + DECLARE_MESSAGE(FailedToObtainLocalPortGitSha, (), "", "Failed to obtain git SHAs for local ports."); DECLARE_MESSAGE(FailedToParseCMakeConsoleOut, (), "", "Failed to parse CMake console output to locate block start/end markers."); + DECLARE_MESSAGE(FailedToParseControl, (msg::path), "", "Failed to parse control file: {path}"); + DECLARE_MESSAGE(FailedToParseJson, (msg::path), "", "Failed to parse JSON file {path}"); + DECLARE_MESSAGE(FailedToParseManifest, (msg::path), "", "Failed to parse manifest file: {path}"); DECLARE_MESSAGE(FailedToProvisionCe, (), "", "Failed to provision vcpkg-ce."); + DECLARE_MESSAGE(FailedToRead, (msg::path, msg::error_msg), "", "Failed to read {path}: {error_msg}"); + DECLARE_MESSAGE(FailedToReadParagraph, (msg::path), "", "Failed to read paragraphs from {path}"); + DECLARE_MESSAGE(FailedToRemoveControl, (msg::path), "", "Failed to remove control file {path}"); DECLARE_MESSAGE(FailedToRunToolToDetermineVersion, (msg::tool_name, msg::path), "Additional information, such as the command line output, if any, will be appended on " @@ -786,6 +804,7 @@ namespace vcpkg "Failed to run \"{path}\" to determine the {tool_name} version."); DECLARE_MESSAGE(FailedToStoreBackToMirror, (), "", "failed to store back to mirror:"); DECLARE_MESSAGE(FailedToStoreBinaryCache, (msg::path), "", "Failed to store binary cache {path}"); + DECLARE_MESSAGE(FailedToWriteManifest, (msg::path), "", "Failed to write manifest file {path}"); DECLARE_MESSAGE(FailedVendorAuthentication, (msg::vendor, msg::url), "", @@ -924,8 +943,6 @@ namespace vcpkg (msg::actual), "{actual} is the provided format string", "invalid format string: {actual}"); - DECLARE_MESSAGE(FailedToParseJson, (msg::path), "", "Failed to parse JSON file {path}"); - DECLARE_MESSAGE(FailedToRead, (msg::path, msg::error_msg), "", "Failed to read {path}: {error_msg}"); DECLARE_MESSAGE(JsonErrorMustBeAnObject, (msg::path), "", "Expected \"{path}\" to be an object."); DECLARE_MESSAGE(LaunchingProgramFailed, (msg::tool_name), @@ -1023,8 +1040,18 @@ namespace vcpkg "{value} is a localized message name like LocalizedMessageMustNotEndWithNewline", "The message named {value} ends with a newline which should be added by formatting " "rather than by localization."); + DECLARE_MESSAGE(ManifestFormatCompleted, (), "", "Succeeded in formatting the manifest files."); DECLARE_MESSAGE(Missing7zHeader, (), "", "Unable to find 7z header."); + DECLARE_MESSAGE(MissingArgFormatManifest, + (), + "", + "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: we will " + "automatically convert all control files passed explicitly."); DECLARE_MESSAGE(MissingExtension, (msg::extension), "", "Missing '{extension}' extension."); + DECLARE_MESSAGE(MissingPortSuggestPullRequest, + (), + "", + "If your port is not listed, please open an issue at and/or consider making a pull request."); DECLARE_MESSAGE(MonoInstructions, (), "", @@ -1136,6 +1163,11 @@ namespace vcpkg "The 'Source' field inside the CONTROL file, or \"name\" field inside the vcpkg.json " "file has the name {package_name} and does not match the port directory \"{path}\"."); DECLARE_MESSAGE(StoredBinaryCache, (msg::path), "", "Stored binary cache: \"{path}\""); + DECLARE_MESSAGE(SuggestGitPull, (), "", "The result may be outdated. Run `git pull` to get the latest results."); + DECLARE_MESSAGE(SuggestResolution, + (msg::command_name, msg::option), + "", + "To attempt to resolve all errors at once, run:\nvcpkg {command_name} --{option}"); DECLARE_MESSAGE(SuggestStartingBashShell, (), "", @@ -1307,36 +1339,4 @@ namespace vcpkg "The message named {value} starts with warning:, it must be changed to prepend " "WarningMessage in code instead."); DECLARE_MESSAGE(WarningsTreatedAsErrors, (), "", "previous warnings being interpreted as errors"); - DECLARE_MESSAGE(FailedToParseManifest, (msg::path), "", "Failed to parse manifest file: {path}"); - DECLARE_MESSAGE(FailedToReadParagraph, (msg::path), "", "Failed to read paragraphs from {path}"); - DECLARE_MESSAGE(FailedToParseControl, (msg::path), "", "Failed to parse control file: {path}"); - DECLARE_MESSAGE(FailedToWriteManifest, (msg::path), "", "Failed to write manifest file {path}"); - DECLARE_MESSAGE(FailedToRemoveControl, (msg::path), "", "Failed to remove control file {path}"); - DECLARE_MESSAGE(FailedToFormatMissingFile, - (), - "", - "No files to format.\nPlease pass either --all, or the explicit files to format or convert."); - DECLARE_MESSAGE(MissingArgFormatManifest, - (), - "", - "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: we will " - "automatically convert all control files passed explicitly."); - DECLARE_MESSAGE(ControlAndManifestFilesPresent, - (msg::path), - "", - "Both a manifest file and a CONTROL file exist in port directory: {path}"); - DECLARE_MESSAGE(ManifestFormatCompleted, (), "", "Succeeded in formatting the manifest files."); - DECLARE_MESSAGE(SuggestGitPull, (), "", "The result may be outdated. Run `git pull` to get the latest results."); - DECLARE_MESSAGE(MissingPortSuggestPullRequest, - (), - "", - "If your port is not listed, please open an issue at and/or consider making a pull request."); - DECLARE_MESSAGE(ArtifactsOptionIncompatibility, (msg::option), "", "--{option} has no effect on find artifact."); - DECLARE_MESSAGE(AddCommandFirstArg, (), "", "The first parameter to add must be 'artifact' or 'port'."); - DECLARE_MESSAGE(FailedToObtainLocalPortGitSha, (), "", "Failed to obtain git SHAs for local ports."); - DECLARE_MESSAGE(ErrorsFound, (), "", "Found the following errors:"); - DECLARE_MESSAGE(SuggestResolution, - (msg::command_name, msg::option), - "", - "To attempt to resolve all errors at once, run:\nvcpkg {command_name} --{option}"); } \ No newline at end of file From e7d5f83877ac22795ffdc736360d26a89de8c472 Mon Sep 17 00:00:00 2001 From: Javier Matos Date: Mon, 8 Aug 2022 12:13:32 -0700 Subject: [PATCH 13/14] removed append_nl function --- include/vcpkg/base/messages.h | 6 ------ src/vcpkg/commands.civerifyversions.cpp | 5 +++-- src/vcpkg/commands.find.cpp | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 7b9d1ef724..79fa268ee9 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -74,12 +74,6 @@ namespace vcpkg return *this; } - LocalizedString& append_nl() - { - m_data.append("\n"); - return *this; - } - friend const char* to_printf_arg(const LocalizedString& s) { return s.data().c_str(); } friend bool operator==(const LocalizedString& lhs, const LocalizedString& rhs) diff --git a/src/vcpkg/commands.civerifyversions.cpp b/src/vcpkg/commands.civerifyversions.cpp index 5c71d0290b..3cf6e65b3c 100644 --- a/src/vcpkg/commands.civerifyversions.cpp +++ b/src/vcpkg/commands.civerifyversions.cpp @@ -399,10 +399,11 @@ namespace vcpkg::Commands::CIVerifyVersions auto message = msg::format(msgErrorsFound); for (auto&& error : errors) { - message.append_nl().append_indent().append_raw(error); + message.append_raw("\n").append_indent().append_raw(error); } - message.append_nl().append(msgSuggestResolution, msg::command_name = "x-add-version", msg::option = "all"); + message.append_raw("\n").append( + msgSuggestResolution, msg::command_name = "x-add-version", msg::option = "all"); msg::println_error(message); diff --git a/src/vcpkg/commands.find.cpp b/src/vcpkg/commands.find.cpp index 31ad257bef..a1216b1e93 100644 --- a/src/vcpkg/commands.find.cpp +++ b/src/vcpkg/commands.find.cpp @@ -188,7 +188,7 @@ namespace vcpkg::Commands if (!enable_json) { msg::println(msg::format(msgSuggestGitPull) - .append_nl() + .append_raw("\n") .append(msgMissingPortSuggestPullRequest) .append_indent() .append_raw("- https://github.com/Microsoft/vcpkg/issues")); From 9d641eaf2268c2e9308b915f7d481cefc64acb36 Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Wed, 17 Aug 2022 18:13:41 -0700 Subject: [PATCH 14/14] Nitpicks: * Change the use of FailedToObtainLocalPortGitSha, FailedToWriteManifest, FailedToRemoveControl, FailedToFormatMissingFile to print the error prefix. * Add missing : in FailedToParseJson. * Delete now-unused JsonErrorFailedToParse and JsonErrorFailedToRead. * Words nitpick on MissingArgFormatManifest (was preexisting). * Change ControlAndManifestFilesPresent to check and add the error prefix rather than using a check form. --- include/vcpkg/base/messages.h | 8 +++----- locales/messages.en.json | 6 ++---- locales/messages.json | 8 ++------ src/vcpkg/base/messages.cpp | 2 -- src/vcpkg/commands.civerifyversions.cpp | 2 +- src/vcpkg/commands.find.cpp | 2 +- src/vcpkg/commands.format-manifest.cpp | 26 ++++++++++++------------- 7 files changed, 22 insertions(+), 32 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 7d06404d27..ed8fe2be18 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -878,7 +878,7 @@ namespace vcpkg "", "Failed to parse CMake console output to locate block start/end markers."); DECLARE_MESSAGE(FailedToParseControl, (msg::path), "", "Failed to parse control file: {path}"); - DECLARE_MESSAGE(FailedToParseJson, (msg::path), "", "Failed to parse JSON file {path}"); + DECLARE_MESSAGE(FailedToParseJson, (msg::path), "", "Failed to parse JSON file: {path}"); DECLARE_MESSAGE(FailedToParseManifest, (msg::path), "", "Failed to parse manifest file: {path}"); DECLARE_MESSAGE(FailedToProvisionCe, (), "", "Failed to provision vcpkg-ce."); DECLARE_MESSAGE(FailedToRead, (msg::path, msg::error_msg), "", "Failed to read {path}: {error_msg}"); @@ -1082,8 +1082,6 @@ namespace vcpkg (msg::system_name, msg::value), "'{value}' is the linkage type vcpkg would did not understand. (Correct values would be static ofr dynamic)", "Invalid {system_name} linkage type: [{value}]"); - DECLARE_MESSAGE(JsonErrorFailedToParse, (msg::path), "", "failed to parse {path}:"); - DECLARE_MESSAGE(JsonErrorFailedToRead, (msg::path, msg::error_msg), "", "failed to read {path}: {error_msg}"); DECLARE_MESSAGE(JsonErrorMustBeAnObject, (msg::path), "", "Expected \"{path}\" to be an object."); DECLARE_MESSAGE(JsonSwitch, (), "", "(Experimental) Request JSON output."); DECLARE_MESSAGE(LaunchingProgramFailed, @@ -1196,8 +1194,8 @@ namespace vcpkg DECLARE_MESSAGE(MissingArgFormatManifest, (), "", - "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: we will " - "automatically convert all control files passed explicitly."); + "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: control " + "files passed explicitly are converted automatically."); DECLARE_MESSAGE(MissingExtension, (msg::extension), "", "Missing '{extension}' extension."); DECLARE_MESSAGE(MissingPortSuggestPullRequest, (), diff --git a/locales/messages.en.json b/locales/messages.en.json index 3c7042804b..a4bb87f61f 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -139,7 +139,7 @@ "FailedToParseBinParagraph": "[sanity check] Failed to parse a serialized binary paragraph.\nPlease open an issue at https://github.com/microsoft/vcpkg, with the following output:\n{error_msg}\nSerialized Binary Paragraph:", "FailedToParseCMakeConsoleOut": "Failed to parse CMake console output to locate block start/end markers.", "FailedToParseControl": "Failed to parse control file: {path}", - "FailedToParseJson": "Failed to parse JSON file {path}", + "FailedToParseJson": "Failed to parse JSON file: {path}", "FailedToParseManifest": "Failed to parse manifest file: {path}", "FailedToProvisionCe": "Failed to provision vcpkg-ce.", "FailedToRead": "Failed to read {path}: {error_msg}", @@ -222,8 +222,6 @@ "InvalidFilename": "Filename cannot contain invalid chars {value}, but was {path}", "InvalidFormatString": "invalid format string: {actual}", "InvalidLinkage": "Invalid {system_name} linkage type: [{value}]", - "JsonErrorFailedToParse": "failed to parse {path}:", - "JsonErrorFailedToRead": "failed to read {path}: {error_msg}", "JsonErrorMustBeAnObject": "Expected \"{path}\" to be an object.", "JsonSwitch": "(Experimental) Request JSON output.", "LaunchingProgramFailed": "Launching {tool_name}:", @@ -253,7 +251,7 @@ "ManifestFormatCompleted": "Succeeded in formatting the manifest files.", "MismatchedBinaryParagraphs": "[sanity check] The serialized binary paragraph was different from the original binary paragraph.\nPlease open an issue at {url}, with the following output:", "Missing7zHeader": "Unable to find 7z header.", - "MissingArgFormatManifest": "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: we will automatically convert all control files passed explicitly.", + "MissingArgFormatManifest": "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: control files passed explicitly are converted automatically.", "MissingExtension": "Missing '{extension}' extension.", "MissingPortSuggestPullRequest": "If your port is not listed, please open an issue at and/or consider making a pull request.", "MissmatchedBinParagraphs": "The serialized binary paragraph was different from the original binary paragraph. Please open an issue at https://github.com/microsoft/vcpkg with the following output:", diff --git a/locales/messages.json b/locales/messages.json index e6aca9a94f..c5883c32bb 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -244,7 +244,7 @@ "FailedToParseCMakeConsoleOut": "Failed to parse CMake console output to locate block start/end markers.", "FailedToParseControl": "Failed to parse control file: {path}", "_FailedToParseControl.comment": "An example of {path} is /foo/bar.", - "FailedToParseJson": "Failed to parse JSON file {path}", + "FailedToParseJson": "Failed to parse JSON file: {path}", "_FailedToParseJson.comment": "An example of {path} is /foo/bar.", "FailedToParseManifest": "Failed to parse manifest file: {path}", "_FailedToParseManifest.comment": "An example of {path} is /foo/bar.", @@ -371,10 +371,6 @@ "_InvalidFormatString.comment": "{actual} is the provided format string", "InvalidLinkage": "Invalid {system_name} linkage type: [{value}]", "_InvalidLinkage.comment": "'{value}' is the linkage type vcpkg would did not understand. (Correct values would be static ofr dynamic) An example of {system_name} is Darwin.", - "JsonErrorFailedToParse": "failed to parse {path}:", - "_JsonErrorFailedToParse.comment": "An example of {path} is /foo/bar.", - "JsonErrorFailedToRead": "failed to read {path}: {error_msg}", - "_JsonErrorFailedToRead.comment": "An example of {path} is /foo/bar. An example of {error_msg} is File Not Found.", "JsonErrorMustBeAnObject": "Expected \"{path}\" to be an object.", "_JsonErrorMustBeAnObject.comment": "An example of {path} is /foo/bar.", "JsonSwitch": "(Experimental) Request JSON output.", @@ -421,7 +417,7 @@ "MismatchedBinaryParagraphs": "[sanity check] The serialized binary paragraph was different from the original binary paragraph.\nPlease open an issue at {url}, with the following output:", "_MismatchedBinaryParagraphs.comment": "A comparison of the original binary paragraph and serialized binary paragraph is expected. An example of {url} is https://github.com/microsoft/vcpkg.", "Missing7zHeader": "Unable to find 7z header.", - "MissingArgFormatManifest": "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: we will automatically convert all control files passed explicitly.", + "MissingArgFormatManifest": "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: control files passed explicitly are converted automatically.", "MissingExtension": "Missing '{extension}' extension.", "_MissingExtension.comment": "An example of {extension} is .exe.", "MissingPortSuggestPullRequest": "If your port is not listed, please open an issue at and/or consider making a pull request.", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 5354ab1142..4df0dba2b3 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -622,8 +622,6 @@ namespace vcpkg REGISTER_MESSAGE(InvalidFilename); REGISTER_MESSAGE(InvalidFormatString); REGISTER_MESSAGE(InvalidLinkage); - REGISTER_MESSAGE(JsonErrorFailedToParse); - REGISTER_MESSAGE(JsonErrorFailedToRead); REGISTER_MESSAGE(JsonErrorMustBeAnObject); REGISTER_MESSAGE(JsonSwitch); REGISTER_MESSAGE(LaunchingProgramFailed); diff --git a/src/vcpkg/commands.civerifyversions.cpp b/src/vcpkg/commands.civerifyversions.cpp index 3cf6e65b3c..a90f4c71e1 100644 --- a/src/vcpkg/commands.civerifyversions.cpp +++ b/src/vcpkg/commands.civerifyversions.cpp @@ -297,7 +297,7 @@ namespace vcpkg::Commands::CIVerifyVersions auto maybe_port_git_tree_map = paths.git_get_local_port_treeish_map(); if (!maybe_port_git_tree_map) { - Checks::msg_exit_with_message( + Checks::msg_exit_with_error( VCPKG_LINE_INFO, msg::format(msgFailedToObtainLocalPortGitSha).append_raw("\n" + maybe_port_git_tree_map.error())); } diff --git a/src/vcpkg/commands.find.cpp b/src/vcpkg/commands.find.cpp index a1216b1e93..98ab86fd01 100644 --- a/src/vcpkg/commands.find.cpp +++ b/src/vcpkg/commands.find.cpp @@ -262,6 +262,6 @@ namespace vcpkg::Commands perform_find_port_and_exit(paths, full_description, enable_json, filter, args.overlay_ports); } - Checks::msg_exit_with_message(VCPKG_LINE_INFO, msgAddCommandFirstArg); + Checks::msg_exit_with_error(VCPKG_LINE_INFO, msgAddCommandFirstArg); } } diff --git a/src/vcpkg/commands.format-manifest.cpp b/src/vcpkg/commands.format-manifest.cpp index 7d37ee15f0..3f9ff0ae78 100644 --- a/src/vcpkg/commands.format-manifest.cpp +++ b/src/vcpkg/commands.format-manifest.cpp @@ -156,20 +156,20 @@ Please open an issue at https://github.com/microsoft/vcpkg, with the following o fs.write_contents(data.file_to_write, Json::stringify(res), ec); if (ec) { - Checks::msg_exit_with_message(VCPKG_LINE_INFO, - msg::format(msgFailedToWriteManifest, msg::path = file_to_write_string) - .append_raw(": ") - .append_raw(ec.message())); + Checks::msg_exit_with_error(VCPKG_LINE_INFO, + msg::format(msgFailedToWriteManifest, msg::path = file_to_write_string) + .append_raw(": ") + .append_raw(ec.message())); } if (data.original_path != data.file_to_write) { fs.remove(data.original_path, ec); if (ec) { - Checks::msg_exit_with_message(VCPKG_LINE_INFO, - msg::format(msgFailedToRemoveControl, msg::path = original_path_string) - .append_raw(": ") - .append_raw(ec.message())); + Checks::msg_exit_with_error(VCPKG_LINE_INFO, + msg::format(msgFailedToRemoveControl, msg::path = original_path_string) + .append_raw(": ") + .append_raw(ec.message())); } } } @@ -210,7 +210,7 @@ namespace vcpkg::Commands::FormatManifest if (!format_all && args.command_arguments.empty()) { - Checks::msg_exit_with_message(VCPKG_LINE_INFO, msgFailedToFormatMissingFile); + Checks::msg_exit_with_error(VCPKG_LINE_INFO, msgFailedToFormatMissingFile); } std::vector to_write; @@ -248,10 +248,10 @@ namespace vcpkg::Commands::FormatManifest auto manifest_exists = fs.exists(manifest_path, IgnoreErrors{}); auto control_exists = fs.exists(control_path, IgnoreErrors{}); - Checks::msg_check_exit(VCPKG_LINE_INFO, - !manifest_exists || !control_exists, - msgControlAndManifestFilesPresent, - msg::path = dir); + if (manifest_exists && control_exists) + { + Checks::msg_exit_with_error(VCPKG_LINE_INFO, msgControlAndManifestFilesPresent, msg::path = dir); + } if (manifest_exists) {