From fb8ebe1440e8c0a26413b134e785f9196662a73d Mon Sep 17 00:00:00 2001 From: Javier Matos Denizac Date: Wed, 14 Sep 2022 13:31:01 -0700 Subject: [PATCH 01/11] Localized messages in statusparagraphs.cpp --- include/vcpkg/base/messages.h | 1 + locales/messages.en.json | 1 + locales/messages.json | 1 + src/vcpkg/base/messages.cpp | 1 + src/vcpkg/statusparagraphs.cpp | 2 +- 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index d463672da5..837a97c9a3 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -1647,4 +1647,5 @@ namespace vcpkg DECLARE_MESSAGE(WhileLookingForSpec, (msg::spec), "", "while looking for {spec}:"); DECLARE_MESSAGE(WindowsOnlyCommand, (), "", "This command only supports Windows."); DECLARE_MESSAGE(WroteNuGetPkgConfInfo, (msg::path), "", "Wrote NuGet package config information to {path}."); + DECLARE_MESSAGE(InsertedNullParagraph, (), "", "Inserted null paragraph"); } diff --git a/locales/messages.en.json b/locales/messages.en.json index d7d091d0cf..1425b52a49 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -216,6 +216,7 @@ "IncorrectNumberOfArgs": "'{command_name}' requires '{expected}' arguments, but '{actual}' were provided.", "InfoSetEnvVar": "You can also set the environment variable '{env_var}' to your editor of choice.", "InitRegistryFailedNoRepo": "Could not create a registry at {path} because this is not a git repository root.\nUse `git init {command_line}` to create a git repository in this folder.", + "InsertedNullParagraph": "Inserted null paragraph", "InstallPackageInstruction": "With a project open, go to Tools->NuGet Package Manager->Package Manager Console and paste:\n Install-Package \"{value}\" -Source \"{path}\"", "InstallRootDir": "(Experimental) Specify the install root directory.", "InstallWithSystemManager": "You may be able to install this tool via your system package manager.", diff --git a/locales/messages.json b/locales/messages.json index c339ec8d63..93ff2ee846 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -355,6 +355,7 @@ "_InfoSetEnvVar.comment": "In this context 'editor' means IDE An example of {env_var} is VCPKG_DEFAULT_TRIPLET.", "InitRegistryFailedNoRepo": "Could not create a registry at {path} because this is not a git repository root.\nUse `git init {command_line}` to create a git repository in this folder.", "_InitRegistryFailedNoRepo.comment": "An example of {path} is /foo/bar. An example of {command_line} is vcpkg install zlib.", + "InsertedNullParagraph": "Inserted null paragraph", "InstallPackageInstruction": "With a project open, go to Tools->NuGet Package Manager->Package Manager Console and paste:\n Install-Package \"{value}\" -Source \"{path}\"", "_InstallPackageInstruction.comment": "'{value}' is the nuget id. An example of {path} is /foo/bar.", "InstallRootDir": "(Experimental) Specify the install root directory.", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 9afec73519..49ad78a68b 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -803,4 +803,5 @@ namespace vcpkg REGISTER_MESSAGE(WhileLookingForSpec); REGISTER_MESSAGE(WindowsOnlyCommand); REGISTER_MESSAGE(WroteNuGetPkgConfInfo); + REGISTER_MESSAGE(InsertedNullParagraph); } diff --git a/src/vcpkg/statusparagraphs.cpp b/src/vcpkg/statusparagraphs.cpp index 366fd96c31..f92fad0a11 100644 --- a/src/vcpkg/statusparagraphs.cpp +++ b/src/vcpkg/statusparagraphs.cpp @@ -124,7 +124,7 @@ namespace vcpkg StatusParagraphs::iterator StatusParagraphs::insert(std::unique_ptr pgh) { - Checks::check_exit(VCPKG_LINE_INFO, pgh != nullptr, "Inserted null paragraph"); + Checks::msg_check_exit(VCPKG_LINE_INFO, pgh != nullptr, msgInsertedNullParagraph); const PackageSpec& spec = pgh->package.spec; const auto ptr = find(spec.name(), spec.triplet(), pgh->package.feature); if (ptr == end()) From 6b77c956c2319846b2a315ed96b6071ed6a80961 Mon Sep 17 00:00:00 2001 From: Javier Matos Denizac Date: Wed, 14 Sep 2022 13:35:31 -0700 Subject: [PATCH 02/11] Localized messages in statusparagraph.cpp --- include/vcpkg/base/messages.h | 1 + locales/messages.en.json | 1 + locales/messages.json | 1 + src/vcpkg/base/messages.cpp | 1 + src/vcpkg/statusparagraph.cpp | 3 +-- 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 837a97c9a3..3e234aaaab 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -1648,4 +1648,5 @@ namespace vcpkg DECLARE_MESSAGE(WindowsOnlyCommand, (), "", "This command only supports Windows."); DECLARE_MESSAGE(WroteNuGetPkgConfInfo, (msg::path), "", "Wrote NuGet package config information to {path}."); DECLARE_MESSAGE(InsertedNullParagraph, (), "", "Inserted null paragraph"); + DECLARE_MESSAGE(ExpectedStatusField, (), "", "Expected 'status' field in status paragraph"); } diff --git a/locales/messages.en.json b/locales/messages.en.json index 1425b52a49..2c53d84cb0 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -142,6 +142,7 @@ "ExpectedCharacterHere": "expected '{expected}' here", "ExpectedFailOrSkip": "expected 'fail', 'skip', or 'pass' here", "ExpectedPortName": "expected a port name here", + "ExpectedStatusField": "Expected 'status' field in status paragraph", "ExpectedTripletName": "expected a triplet name here", "ExpectedValueForOption": "expected value after --{option}.", "ExportingPackage": "Exporting {package_name}...", diff --git a/locales/messages.json b/locales/messages.json index 93ff2ee846..f7098e6235 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -247,6 +247,7 @@ "_ExpectedCharacterHere.comment": "{expected} is a locale-invariant delimiter; for example, the ':' or '=' in 'zlib:x64-windows=skip'", "ExpectedFailOrSkip": "expected 'fail', 'skip', or 'pass' here", "ExpectedPortName": "expected a port name here", + "ExpectedStatusField": "Expected 'status' field in status paragraph", "ExpectedTripletName": "expected a triplet name here", "ExpectedValueForOption": "expected value after --{option}.", "_ExpectedValueForOption.comment": "An example of {option} is editable.", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 49ad78a68b..0284eb095a 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -804,4 +804,5 @@ namespace vcpkg REGISTER_MESSAGE(WindowsOnlyCommand); REGISTER_MESSAGE(WroteNuGetPkgConfInfo); REGISTER_MESSAGE(InsertedNullParagraph); + REGISTER_MESSAGE(ExpectedStatusField); } diff --git a/src/vcpkg/statusparagraph.cpp b/src/vcpkg/statusparagraph.cpp index efd4a63332..c9daa91885 100644 --- a/src/vcpkg/statusparagraph.cpp +++ b/src/vcpkg/statusparagraph.cpp @@ -24,8 +24,7 @@ namespace vcpkg StatusParagraph::StatusParagraph(Paragraph&& fields) : want(Want::ERROR_STATE), state(InstallState::ERROR_STATE) { auto status_it = fields.find(BinaryParagraphRequiredField::STATUS); - Checks::check_maybe_upgrade( - VCPKG_LINE_INFO, status_it != fields.end(), "Expected 'Status' field in status paragraph"); + Checks::msg_check_maybe_upgrade(VCPKG_LINE_INFO, status_it != fields.end(), msgExpectedStatusField); std::string status_field = std::move(status_it->second.first); fields.erase(status_it); From 8fc61a6e0977cbeb3f5510dd5115a45fd182b4bf Mon Sep 17 00:00:00 2001 From: Javier Matos Denizac Date: Fri, 16 Sep 2022 11:08:19 -0700 Subject: [PATCH 03/11] Localized messages for remove.cpp --- include/vcpkg/base/messages.h | 28 ++++++++++++++++++++++ locales/messages.en.json | 13 +++++++++++ locales/messages.json | 19 +++++++++++++++ src/vcpkg/base/messages.cpp | 13 +++++++++++ src/vcpkg/remove.cpp | 44 +++++++++++++++-------------------- 5 files changed, 92 insertions(+), 25 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 3e234aaaab..8cca589e7b 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -1649,4 +1649,32 @@ namespace vcpkg DECLARE_MESSAGE(WroteNuGetPkgConfInfo, (msg::path), "", "Wrote NuGet package config information to {path}."); DECLARE_MESSAGE(InsertedNullParagraph, (), "", "Inserted null paragraph"); DECLARE_MESSAGE(ExpectedStatusField, (), "", "Expected 'status' field in status paragraph"); + DECLARE_MESSAGE(PackageAlreadyRemoved, (msg::spec), "", "unable to remove package {spec}: already removed"); + DECLARE_MESSAGE(FailedSymlinkStatus, + (msg::path, msg::error_msg), + "", + "failed: symlink_status({path}): {error_msg}"); + DECLARE_MESSAGE(FailedToRemoveDirectory, (msg::path, msg::error_msg), "", "failed:remove({path}): {error_msg}"); + DECLARE_MESSAGE(InvalidFileType, (msg::path), "", "{path}: cannot handle file type"); + DECLARE_MESSAGE(FileNotFound, (msg::path), "", "{path}: file not found"); + DECLARE_MESSAGE(InvalidOptionForRemove, (), "", "'remove' accepts either libraries or '--outdated'"); + DECLARE_MESSAGE(NoOutdatedPackages, (), "", "There are no outdated packages."); + DECLARE_MESSAGE(PurgeOptionConflict, (), "", "cannot specify both --no-purge and --purge."); + DECLARE_MESSAGE(EmptyRemovePlan, (), "", "Remove plan cannot be empty"); + DECLARE_MESSAGE(AdditionalPackagesToRemove, + (), + "", + "Additional packages (*) need to be removed to complete this operation."); + DECLARE_MESSAGE(AddRecurseOption, + (), + "", + "If you are sure you want to remove them, run the command with the --recurse option."); + DECLARE_MESSAGE(RemovePackageConflict, + (msg::spec), + "", + "Another installed package matches the name of an unmatched request. Did you mean {spec}?"); + DECLARE_MESSAGE(RemoveDependencies, + (), + "", + "To remove dependencies in manifest mode, edit your manifest (vcpkg.json) and run 'install'."); } diff --git a/locales/messages.en.json b/locales/messages.en.json index 2c53d84cb0..bc78d77256 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -4,6 +4,7 @@ "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.", + "AddRecurseOption": "If you are sure you want to remove them, run the command with the --recurse option.", "AddTripletExpressionNotAllowed": "triplet expressions are not allowed here. You may want to change `{package_name}:{triplet}` to `{package_name}` instead.", "AddVersionAddedVersionToFile": "added version {version} to {path}", "AddVersionCommitChangesReminder": "Did you remember to commit your changes?", @@ -32,6 +33,7 @@ "AddVersionVersionAlreadyInFile": "version {version} is already in {path}", "AddVersionVersionIs": "version: {version}", "AddingCompletionEntry": "Adding vcpkg completion entry to {path}.", + "AdditionalPackagesToRemove": "Additional packages (*) need to be removed to complete this operation.", "AllFormatArgsRawArgument": "format string \"{value}\" contains a raw format argument", "AllFormatArgsUnbalancedBraces": "unbalanced brace in format string \"{value}\"", "AllPackagesAreUpdated": "All installed packages are up-to-date with the local portfile.", @@ -113,6 +115,7 @@ "EmailVcpkgTeam": "Send an email to {url} with any feedback.", "EmptyArg": "The option --{option} must be passed a non-empty argument.", "EmptyLicenseExpression": "SPDX license expression was empty.", + "EmptyRemovePlan": "Remove plan cannot be empty", "EnvStrFailedToExtract": "could not expand the environment string:", "ErrorDetectingCompilerInfo": "while detecting compiler information:\nThe log file content at \"{path}\" is:", "ErrorIndividualPackagesUnsupported": "In manifest mode, `vcpkg install` does not support individual package arguments.\nTo install additional packages, edit vcpkg.json and then run `vcpkg install` without any package arguments.", @@ -147,6 +150,7 @@ "ExpectedValueForOption": "expected value after --{option}.", "ExportingPackage": "Exporting {package_name}...", "ExtendedDocumentationAtUrl": "Extended documentation available at '{url}'.", + "FailedSymlinkStatus": "failed: symlink_status({path}): {error_msg}", "FailedToExtract": "Failed to extract \"{path}\":", "FailedToFindPortFeature": "Could not find {feature} in {spec}.", "FailedToFormatMissingFile": "No files to format.\nPlease pass either --all, or the explicit files to format or convert.", @@ -164,12 +168,14 @@ "FailedToRead": "Failed to read {path}: {error_msg}", "FailedToReadParagraph": "Failed to read paragraphs from {path}", "FailedToRemoveControl": "Failed to remove control file {path}", + "FailedToRemoveDirectory": "failed:remove({path}): {error_msg}", "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.", "FeedbackAppreciated": "Thank you for your feedback!", + "FileNotFound": "{path}: file not found", "FishCompletion": "vcpkg fish completion is already added at \"{path}\".", "FollowingPackagesMissingControl": "The following packages do not have a valid CONTROL or vcpkg.json:", "FollowingPackagesNotInstalled": "The following packages are not installed:", @@ -249,9 +255,11 @@ "InvalidBuildInfo": "Invalid BUILD_INFO file for package: {error_msg}", "InvalidCommandArgSort": "Value of --sort must be one of 'lexicographical', 'topological', 'reverse'.", "InvalidCommitId": "Invalid commit id {value}", + "InvalidFileType": "{path}: cannot handle file type", "InvalidFilename": "Filename cannot contain invalid chars {value}, but was {path}", "InvalidFormatString": "invalid format string: {actual}", "InvalidLinkage": "Invalid {system_name} linkage type: [{value}]", + "InvalidOptionForRemove": "'remove' accepts either libraries or '--outdated'", "IrregularFile": "path was not a regular file: {path}", "JsonErrorMustBeAnObject": "Expected \"{path}\" to be an object.", "JsonSwitch": "(Experimental) Request JSON output.", @@ -302,6 +310,7 @@ "NoCachedPackages": "No packages are cached.", "NoInstalledPackages": "No packages are installed. Did you mean `search`?", "NoLocalizationForMessages": "No localized messages for the following: ", + "NoOutdatedPackages": "There are no outdated packages.", "NoRegistryForPort": "no registry configured for port {package_name}", "NoteMessage": "note: ", "NugetPackageFileSucceededButCreationFailed": "NuGet package creation succeeded, but no .nupkg was produced. Expected: \"{path}\"", @@ -309,6 +318,7 @@ "OptionRequired": "--{option} option is required.", "OptionRequiresOption": "--{value} requires --{option}", "OriginalBinParagraphHeader": "\nOriginal Binary Paragraph", + "PackageAlreadyRemoved": "unable to remove package {spec}: already removed", "PackageFailedtWhileExtracting": "'{value}' failed while extracting {path}.", "PackageRootDir": "(Experimental) Specify the packages root directory.", "PackagesToInstall": "The following packages will be built and installed:", @@ -336,8 +346,11 @@ "ProcessorArchitectureMissing": "The required environment variable %PROCESSOR_ARCHITECTURE% is missing.", "ProcessorArchitectureW6432Malformed": "Failed to parse %PROCESSOR_ARCHITEW6432% ({arch}) as a valid CPU architecture. Falling back to %PROCESSOR_ARCHITECTURE%.", "ProgramReturnedNonzeroExitCode": "{tool_name} failed with exit code: ({exit_code}).", + "PurgeOptionConflict": "cannot specify both --no-purge and --purge.", "PushingVendorFailed": "Pushing {vendor} to \"{path}\" failed. Use --debug for more information.", "RegistryCreated": "Successfully created registry at {path}", + "RemoveDependencies": "To remove dependencies in manifest mode, edit your manifest (vcpkg.json) and run 'install'.", + "RemovePackageConflict": "Another installed package matches the name of an unmatched request. Did you mean {spec}?", "RemovingPackage": "Removing {action_index}/{count} {spec}", "ReplaceSecretsError": "Replace secretes produced the following error: '{error_msg}'", "RestoredPackage": "Restored package from \"{path}\"", diff --git a/locales/messages.json b/locales/messages.json index f7098e6235..6cb9f0a2c9 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -7,6 +7,7 @@ "AddPortRequiresManifest": "'{command_line}' requires an active manifest file.", "_AddPortRequiresManifest.comment": "An example of {command_line} is vcpkg install zlib.", "AddPortSucceeded": "Succeeded in adding ports to vcpkg.json file.", + "AddRecurseOption": "If you are sure you want to remove them, run the command with the --recurse option.", "AddTripletExpressionNotAllowed": "triplet expressions are not allowed here. You may want to change `{package_name}:{triplet}` to `{package_name}` instead.", "_AddTripletExpressionNotAllowed.comment": "An example of {package_name} is zlib. An example of {triplet} is x64-windows.", "AddVersionAddedVersionToFile": "added version {version} to {path}", @@ -57,6 +58,7 @@ "_AddVersionVersionIs.comment": "An example of {version} is 1.3.8.", "AddingCompletionEntry": "Adding vcpkg completion entry to {path}.", "_AddingCompletionEntry.comment": "An example of {path} is /foo/bar.", + "AdditionalPackagesToRemove": "Additional packages (*) need to be removed to complete this operation.", "AllFormatArgsRawArgument": "format string \"{value}\" contains a raw format argument", "_AllFormatArgsRawArgument.comment": "example of {value} is 'foo {} bar'", "AllFormatArgsUnbalancedBraces": "unbalanced brace in format string \"{value}\"", @@ -201,6 +203,7 @@ "EmptyArg": "The option --{option} must be passed a non-empty argument.", "_EmptyArg.comment": "An example of {option} is editable.", "EmptyLicenseExpression": "SPDX license expression was empty.", + "EmptyRemovePlan": "Remove plan cannot be empty", "EnvStrFailedToExtract": "could not expand the environment string:", "ErrorDetectingCompilerInfo": "while detecting compiler information:\nThe log file content at \"{path}\" is:", "_ErrorDetectingCompilerInfo.comment": "An example of {path} is /foo/bar.", @@ -255,6 +258,8 @@ "_ExportingPackage.comment": "An example of {package_name} is zlib.", "ExtendedDocumentationAtUrl": "Extended documentation available at '{url}'.", "_ExtendedDocumentationAtUrl.comment": "An example of {url} is https://github.com/microsoft/vcpkg.", + "FailedSymlinkStatus": "failed: symlink_status({path}): {error_msg}", + "_FailedSymlinkStatus.comment": "An example of {path} is /foo/bar. An example of {error_msg} is File Not Found.", "FailedToExtract": "Failed to extract \"{path}\":", "_FailedToExtract.comment": "An example of {path} is /foo/bar.", "FailedToFindPortFeature": "Could not find {feature} in {spec}.", @@ -283,6 +288,8 @@ "_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.", + "FailedToRemoveDirectory": "failed:remove({path}): {error_msg}", + "_FailedToRemoveDirectory.comment": "An example of {path} is /foo/bar. An example of {error_msg} is File Not Found.", "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:", @@ -293,6 +300,8 @@ "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.", "FeedbackAppreciated": "Thank you for your feedback!", + "FileNotFound": "{path}: file not found", + "_FileNotFound.comment": "An example of {path} is /foo/bar.", "FishCompletion": "vcpkg fish completion is already added at \"{path}\".", "_FishCompletion.comment": "An example of {path} is /foo/bar.", "FollowingPackagesMissingControl": "The following packages do not have a valid CONTROL or vcpkg.json:", @@ -409,12 +418,15 @@ "InvalidCommandArgSort": "Value of --sort must be one of 'lexicographical', 'topological', 'reverse'.", "InvalidCommitId": "Invalid commit id {value}", "_InvalidCommitId.comment": "'{value}' is a commit id.", + "InvalidFileType": "{path}: cannot handle file type", + "_InvalidFileType.comment": "An example of {path} is /foo/bar.", "InvalidFilename": "Filename cannot contain invalid chars {value}, but was {path}", "_InvalidFilename.comment": "'{value}' is a list of invalid characters. I.e. \\/:*?<>| An example of {path} is /foo/bar.", "InvalidFormatString": "invalid format string: {actual}", "_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.", + "InvalidOptionForRemove": "'remove' accepts either libraries or '--outdated'", "IrregularFile": "path was not a regular file: {path}", "_IrregularFile.comment": "An example of {path} is /foo/bar.", "JsonErrorMustBeAnObject": "Expected \"{path}\" to be an object.", @@ -492,6 +504,7 @@ "NoInstalledPackages": "No packages are installed. Did you mean `search`?", "_NoInstalledPackages.comment": "The name 'search' is the name of a command that is not localized.", "NoLocalizationForMessages": "No localized messages for the following: ", + "NoOutdatedPackages": "There are no outdated packages.", "NoRegistryForPort": "no registry configured for port {package_name}", "_NoRegistryForPort.comment": "An example of {package_name} is zlib.", "NoteMessage": "note: ", @@ -504,6 +517,8 @@ "OptionRequiresOption": "--{value} requires --{option}", "_OptionRequiresOption.comment": "{value} is a command line option. An example of {option} is editable.", "OriginalBinParagraphHeader": "\nOriginal Binary Paragraph", + "PackageAlreadyRemoved": "unable to remove package {spec}: already removed", + "_PackageAlreadyRemoved.comment": "An example of {spec} is zlib:x64-windows.", "PackageFailedtWhileExtracting": "'{value}' failed while extracting {path}.", "_PackageFailedtWhileExtracting.comment": "'{value}' is either a tool name or a package name. An example of {path} is /foo/bar.", "PackageRootDir": "(Experimental) Specify the packages root directory.", @@ -545,10 +560,14 @@ "_ProcessorArchitectureW6432Malformed.comment": "An example of {arch} is x64.", "ProgramReturnedNonzeroExitCode": "{tool_name} failed with exit code: ({exit_code}).", "_ProgramReturnedNonzeroExitCode.comment": "The program's console output is appended after this. An example of {tool_name} is aria2. An example of {exit_code} is 127.", + "PurgeOptionConflict": "cannot specify both --no-purge and --purge.", "PushingVendorFailed": "Pushing {vendor} to \"{path}\" failed. Use --debug for more information.", "_PushingVendorFailed.comment": "An example of {vendor} is Azure. An example of {path} is /foo/bar.", "RegistryCreated": "Successfully created registry at {path}", "_RegistryCreated.comment": "An example of {path} is /foo/bar.", + "RemoveDependencies": "To remove dependencies in manifest mode, edit your manifest (vcpkg.json) and run 'install'.", + "RemovePackageConflict": "Another installed package matches the name of an unmatched request. Did you mean {spec}?", + "_RemovePackageConflict.comment": "An example of {spec} is zlib:x64-windows.", "RemovingPackage": "Removing {action_index}/{count} {spec}", "_RemovingPackage.comment": "An example of {action_index} is 340. An example of {count} is 42. An example of {spec} is zlib:x64-windows.", "ReplaceSecretsError": "Replace secretes produced the following error: '{error_msg}'", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 0284eb095a..722deac8b3 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -805,4 +805,17 @@ namespace vcpkg REGISTER_MESSAGE(WroteNuGetPkgConfInfo); REGISTER_MESSAGE(InsertedNullParagraph); REGISTER_MESSAGE(ExpectedStatusField); + REGISTER_MESSAGE(PackageAlreadyRemoved); + REGISTER_MESSAGE(FailedSymlinkStatus); + REGISTER_MESSAGE(FailedToRemoveDirectory); + REGISTER_MESSAGE(InvalidFileType); + REGISTER_MESSAGE(FileNotFound); + REGISTER_MESSAGE(RemoveDependencies); + REGISTER_MESSAGE(InvalidOptionForRemove); + REGISTER_MESSAGE(NoOutdatedPackages); + REGISTER_MESSAGE(PurgeOptionConflict); + REGISTER_MESSAGE(EmptyRemovePlan); + REGISTER_MESSAGE(AdditionalPackagesToRemove); + REGISTER_MESSAGE(AddRecurseOption); + REGISTER_MESSAGE(RemovePackageConflict); } diff --git a/src/vcpkg/remove.cpp b/src/vcpkg/remove.cpp index 2a483d4fbd..f5c06c1193 100644 --- a/src/vcpkg/remove.cpp +++ b/src/vcpkg/remove.cpp @@ -26,8 +26,7 @@ namespace vcpkg::Remove { auto maybe_ipv = status_db->get_installed_package_view(spec); - Checks::check_exit( - VCPKG_LINE_INFO, maybe_ipv.has_value(), "unable to remove package %s: already removed", spec); + Checks::msg_check_exit(VCPKG_LINE_INFO, maybe_ipv.has_value(), msgPackageAlreadyRemoved, msg::spec = spec); auto&& ipv = maybe_ipv.value_or_exit(VCPKG_LINE_INFO); @@ -52,7 +51,7 @@ namespace vcpkg::Remove const auto status = fs.symlink_status(target, ec); if (ec) { - print2(Color::error, "failed: symlink_status(", target, "): ", ec.message(), "\n"); + msg::println_error(msgFailedSymlinkStatus, msg::path = target, msg::error_msg = ec.message()); continue; } @@ -65,16 +64,17 @@ namespace vcpkg::Remove fs.remove(target, ec); if (ec) { - vcpkg::printf(Color::error, "failed: remove(%s): %s\n", target, ec.message()); + msg::println_error( + msgFailedToRemoveDirectory, msg::path = target, msg::error_msg = ec.message()); } } else if (vcpkg::exists(status)) { - vcpkg::printf(Color::warning, "Warning: %s: cannot handle file type\n", target); + msg::println_warning(msgInvalidFileType, msg::path = target); } else { - vcpkg::printf(Color::warning, "Warning: %s: file not found\n", target); + msg::println_warning(msgFileNotFound, msg::path = target); } } @@ -87,7 +87,7 @@ namespace vcpkg::Remove fs.remove(*b, ec); if (ec) { - print2(Color::error, "failed: ", ec.message(), "\n"); + msg::write_unlocalized_text_to_stdout(Color::error, ec.message()); } } } @@ -125,10 +125,10 @@ namespace vcpkg::Remove switch (plan_type) { case RemovePlanType::NOT_INSTALLED: - print2("The following packages are not installed, so not removed:\n", as_string, "\n"); + msg::println(msg::format(msgFollowingPackagesNotInstalled).append_raw(as_string)); continue; case RemovePlanType::REMOVE: - print2("The following packages will be removed:\n", as_string, "\n"); + msg::println(msg::format(msgPackagesToRemove).append_raw("\n" + as_string)); continue; default: Checks::unreachable(VCPKG_LINE_INFO); } @@ -192,9 +192,7 @@ namespace vcpkg::Remove { if (paths.manifest_mode_enabled()) { - Checks::exit_maybe_upgrade( - VCPKG_LINE_INFO, - "To remove dependencies in manifest mode, edit your manifest (vcpkg.json) and run 'install'."); + Checks::msg_exit_maybe_upgrade(VCPKG_LINE_INFO, msgRemoveDependencies); } const ParsedArguments options = args.parse_arguments(COMMAND_STRUCTURE); @@ -204,7 +202,7 @@ namespace vcpkg::Remove { if (args.command_arguments.size() != 0) { - print2(Color::error, "Error: 'remove' accepts either libraries or '--outdated'\n"); + msg::println_error(msgInvalidOptionForRemove); Checks::exit_fail(VCPKG_LINE_INFO); } @@ -216,7 +214,7 @@ namespace vcpkg::Remove if (specs.empty()) { - print2(Color::success, "There are no outdated packages.\n"); + msg::println(Color::success, msgNoOutdatedPackages); Checks::exit_success(VCPKG_LINE_INFO); } } @@ -224,7 +222,7 @@ namespace vcpkg::Remove { if (args.command_arguments.size() < 1) { - print2(Color::error, "Error: 'remove' accepts either libraries or '--outdated'\n"); + msg::println_error(msgInvalidOptionForRemove); Checks::exit_fail(VCPKG_LINE_INFO); } specs = Util::fmap(args.command_arguments, [&](auto&& arg) { @@ -236,8 +234,8 @@ namespace vcpkg::Remove const bool no_purge = Util::Sets::contains(options.switches, OPTION_NO_PURGE); if (no_purge && Util::Sets::contains(options.switches, OPTION_PURGE)) { - print2(Color::error, "Error: cannot specify both --no-purge and --purge.\n"); - print2(COMMAND_STRUCTURE.example_text); + msg::println_error(msgPurgeOptionConflict); + msg::write_unlocalized_text_to_stdout(Color::none, COMMAND_STRUCTURE.example_text); Checks::exit_fail(VCPKG_LINE_INFO); } const Purge purge = no_purge ? Purge::NO : Purge::YES; @@ -246,7 +244,7 @@ namespace vcpkg::Remove const bool dry_run = Util::Sets::contains(options.switches, OPTION_DRY_RUN); const std::vector remove_plan = create_remove_plan(specs, status_db); - Checks::check_exit(VCPKG_LINE_INFO, !remove_plan.empty(), "Remove plan cannot be empty"); + Checks::msg_check_exit(VCPKG_LINE_INFO, !remove_plan.empty(), msgEmptyRemovePlan); std::map> group_by_plan_type; Util::group_by(remove_plan, &group_by_plan_type, [](const RemovePlanAction& p) { return p.plan_type; }); @@ -259,12 +257,11 @@ namespace vcpkg::Remove if (has_non_user_requested_packages) { - print2(Color::warning, "Additional packages (*) need to be removed to complete this operation.\n"); + msg::println_warning(msgAdditionalPackagesToRemove); if (!is_recursive) { - print2(Color::warning, - "If you are sure you want to remove them, run the command with the --recurse option\n"); + msg::println_warning(msgAddRecurseOption); Checks::exit_fail(VCPKG_LINE_INFO); } } @@ -280,10 +277,7 @@ namespace vcpkg::Remove if (package->is_installed() && !package->package.is_feature() && package->package.spec.name() == action.spec.name()) { - print2(Color::warning, - "Another installed package matches the name of an unmatched request. Did you mean ", - package->package.spec, - "?\n"); + msg::println_warning(msgRemovePackageConflict, msg::spec = package->package.spec); } } } From 4e59528e1931a1c0ee8fd662ee308c2fe920e57c Mon Sep 17 00:00:00 2001 From: Javier Matos Denizac Date: Fri, 16 Sep 2022 12:23:00 -0700 Subject: [PATCH 04/11] Localized messages in portfileprovider.cpp --- include/vcpkg/base/messages.h | 11 +++++++++ locales/messages.en.json | 4 ++++ locales/messages.json | 8 +++++++ src/vcpkg/base/messages.cpp | 4 ++++ src/vcpkg/portfileprovider.cpp | 43 +++++++++++++++++++--------------- 5 files changed, 51 insertions(+), 19 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 8cca589e7b..6b3e573897 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -1661,6 +1661,10 @@ namespace vcpkg DECLARE_MESSAGE(NoOutdatedPackages, (), "", "There are no outdated packages."); DECLARE_MESSAGE(PurgeOptionConflict, (), "", "cannot specify both --no-purge and --purge."); DECLARE_MESSAGE(EmptyRemovePlan, (), "", "Remove plan cannot be empty"); + DECLARE_MESSAGE(FailedToLoadPort, + (msg::package_name, msg::path), + "", + "Failed to load port {package_name} from {path}"); DECLARE_MESSAGE(AdditionalPackagesToRemove, (), "", @@ -1677,4 +1681,11 @@ namespace vcpkg (), "", "To remove dependencies in manifest mode, edit your manifest (vcpkg.json) and run 'install'."); + DECLARE_MESSAGE(OverlayPatchDir, (msg::path), "", "Overlay path \"{path}\" must exist and must be a directory."); + DECLARE_MESSAGE(MismatchedNames, + (msg::package_name, msg::actual), + "{actual} is the port name found", + "names did not match: '{package_name}' != '{actual}'"); + DECLARE_MESSAGE(FailedToLoadPortFrom, (msg::path), "", "Failed to load port from {path}"); + } diff --git a/locales/messages.en.json b/locales/messages.en.json index bc78d77256..eec7b12b4e 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -155,6 +155,8 @@ "FailedToFindPortFeature": "Could not find {feature} in {spec}.", "FailedToFormatMissingFile": "No files to format.\nPlease pass either --all, or the explicit files to format or convert.", "FailedToLoadInstalledManifest": "The control or mnaifest file for {spec} could not be loaded due to the following error. Please remove {spec} and re-attempt.", + "FailedToLoadPort": "Failed to load port {package_name} from {path}", + "FailedToLoadPortFrom": "Failed to load port from {path}", "FailedToLocateSpec": "Failed to locate spec in graph: {spec}", "FailedToObtainDependencyVersion": "Cannot find desired dependency version.", "FailedToObtainLocalPortGitSha": "Failed to obtain git SHAs for local ports.", @@ -289,6 +291,7 @@ "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.", "MismatchedFiles": "file to store does not match hash", + "MismatchedNames": "names did not match: '{package_name}' != '{actual}'", "Missing7zHeader": "Unable to find 7z header.", "MissingArgFormatManifest": "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: control files passed explicitly are converted automatically.", "MissingDependency": "Package {spec} is installed, but dependency {package_name} is not.", @@ -318,6 +321,7 @@ "OptionRequired": "--{option} option is required.", "OptionRequiresOption": "--{value} requires --{option}", "OriginalBinParagraphHeader": "\nOriginal Binary Paragraph", + "OverlayPatchDir": "Overlay path \"{path}\" must exist and must be a directory.", "PackageAlreadyRemoved": "unable to remove package {spec}: already removed", "PackageFailedtWhileExtracting": "'{value}' failed while extracting {path}.", "PackageRootDir": "(Experimental) Specify the packages root directory.", diff --git a/locales/messages.json b/locales/messages.json index 6cb9f0a2c9..f28a1b3c1e 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -267,6 +267,10 @@ "FailedToFormatMissingFile": "No files to format.\nPlease pass either --all, or the explicit files to format or convert.", "FailedToLoadInstalledManifest": "The control or mnaifest file for {spec} could not be loaded due to the following error. Please remove {spec} and re-attempt.", "_FailedToLoadInstalledManifest.comment": "An example of {spec} is zlib:x64-windows.", + "FailedToLoadPort": "Failed to load port {package_name} from {path}", + "_FailedToLoadPort.comment": "An example of {package_name} is zlib. An example of {path} is /foo/bar.", + "FailedToLoadPortFrom": "Failed to load port from {path}", + "_FailedToLoadPortFrom.comment": "An example of {path} is /foo/bar.", "FailedToLocateSpec": "Failed to locate spec in graph: {spec}", "_FailedToLocateSpec.comment": "An example of {spec} is zlib:x64-windows.", "FailedToObtainDependencyVersion": "Cannot find desired dependency version.", @@ -473,6 +477,8 @@ "_LocalizedMessageMustNotEndWithNewline.comment": "{value} is a localized message name like LocalizedMessageMustNotEndWithNewline", "ManifestFormatCompleted": "Succeeded in formatting the manifest files.", "MismatchedFiles": "file to store does not match hash", + "MismatchedNames": "names did not match: '{package_name}' != '{actual}'", + "_MismatchedNames.comment": "{actual} is the port name found An example of {package_name} is zlib.", "Missing7zHeader": "Unable to find 7z header.", "MissingArgFormatManifest": "format-manifest was passed --convert-control without '--all'.\nThis doesn't do anything: control files passed explicitly are converted automatically.", "MissingDependency": "Package {spec} is installed, but dependency {package_name} is not.", @@ -517,6 +523,8 @@ "OptionRequiresOption": "--{value} requires --{option}", "_OptionRequiresOption.comment": "{value} is a command line option. An example of {option} is editable.", "OriginalBinParagraphHeader": "\nOriginal Binary Paragraph", + "OverlayPatchDir": "Overlay path \"{path}\" must exist and must be a directory.", + "_OverlayPatchDir.comment": "An example of {path} is /foo/bar.", "PackageAlreadyRemoved": "unable to remove package {spec}: already removed", "_PackageAlreadyRemoved.comment": "An example of {spec} is zlib:x64-windows.", "PackageFailedtWhileExtracting": "'{value}' failed while extracting {path}.", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 722deac8b3..97ab3e9dee 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -818,4 +818,8 @@ namespace vcpkg REGISTER_MESSAGE(AdditionalPackagesToRemove); REGISTER_MESSAGE(AddRecurseOption); REGISTER_MESSAGE(RemovePackageConflict); + REGISTER_MESSAGE(FailedToLoadPort); + REGISTER_MESSAGE(OverlayPatchDir); + REGISTER_MESSAGE(MismatchedNames); + REGISTER_MESSAGE(FailedToLoadPortFrom); } diff --git a/src/vcpkg/portfileprovider.cpp b/src/vcpkg/portfileprovider.cpp index d1cef89f9c..16aa537293 100644 --- a/src/vcpkg/portfileprovider.cpp +++ b/src/vcpkg/portfileprovider.cpp @@ -196,10 +196,10 @@ namespace vcpkg { // This should change to a soft error when ParseExpected is eliminated. print_error_message(maybe_control_file.error()); - Checks::exit_maybe_upgrade(VCPKG_LINE_INFO, - "Error: Failed to load port %s from %s", - version_spec.port_name, - path->path); + Checks::msg_exit_maybe_upgrade(VCPKG_LINE_INFO, + msgFailedToLoadPort, + msg::package_name = version_spec.port_name, + msg::path = path->path); } } else @@ -258,10 +258,10 @@ namespace vcpkg { Debug::print("Using overlay: ", overlay, "\n"); - Checks::check_exit(VCPKG_LINE_INFO, - vcpkg::is_directory(m_fs.status(overlay, VCPKG_LINE_INFO)), - "Error: Overlay path \"%s\" must exist and must be a directory", - overlay); + Checks::msg_check_exit(VCPKG_LINE_INFO, + vcpkg::is_directory(m_fs.status(overlay, VCPKG_LINE_INFO)), + msgOverlayPatchDir, + msg::path = overlay); } } @@ -289,8 +289,10 @@ namespace vcpkg else { print_error_message(maybe_scf.error()); - Checks::exit_maybe_upgrade( - VCPKG_LINE_INFO, "Error: Failed to load port %s from %s", port_name, ports_dir); + Checks::msg_exit_maybe_upgrade(VCPKG_LINE_INFO, + msgFailedToLoadPort, + msg::package_name = port_name, + msg::path = ports_dir); } continue; @@ -307,18 +309,21 @@ namespace vcpkg { return SourceControlFileAndLocation{std::move(scf), std::move(ports_spec)}; } - Checks::exit_maybe_upgrade( + Checks::msg_exit_maybe_upgrade( VCPKG_LINE_INFO, - "Error: Failed to load port from %s: names did not match: '%s' != '%s'", - ports_spec, - port_name, - scf->core_paragraph->name); + msg::format(msgFailedToLoadPort, msg::package_name = port_name, msg::path = ports_spec) + .append_raw("\n") + .append(msgMismatchedNames, + msg::package_name = port_name, + msg::actual = scf->core_paragraph->name)); } else { print_error_message(found_scf.error()); - Checks::exit_maybe_upgrade( - VCPKG_LINE_INFO, "Error: Failed to load port %s from %s", port_name, ports_dir); + Checks::msg_exit_maybe_upgrade(VCPKG_LINE_INFO, + msgFailedToLoadPort, + msg::package_name = port_name, + msg::path = ports_dir); } } } @@ -358,8 +363,8 @@ namespace vcpkg else { print_error_message(maybe_scf.error()); - Checks::exit_maybe_upgrade( - VCPKG_LINE_INFO, "Error: Failed to load port from %s", ports_dir); + Checks::msg_exit_maybe_upgrade( + VCPKG_LINE_INFO, msgFailedToLoadPortFrom, msg::path = ports_dir); } continue; From 64cefa777b35717d1427628e42bacff308e96a94 Mon Sep 17 00:00:00 2001 From: Javier Matos Denizac Date: Fri, 16 Sep 2022 12:26:41 -0700 Subject: [PATCH 05/11] Sorted messages --- include/vcpkg/base/messages.h | 107 +++++++++++++++++----------------- src/vcpkg/base/messages.cpp | 42 ++++++------- 2 files changed, 74 insertions(+), 75 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 6b3e573897..53b81615c4 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -462,11 +462,19 @@ namespace vcpkg "", "The first argument to '{command_line}' must be 'artifact' or 'port'."); DECLARE_MESSAGE(AddingCompletionEntry, (msg::path), "", "Adding vcpkg completion entry to {path}."); + DECLARE_MESSAGE(AdditionalPackagesToRemove, + (), + "", + "Additional packages (*) need to be removed to complete this operation."); DECLARE_MESSAGE(AddPortRequiresManifest, (msg::command_line), "", "'{command_line}' requires an active manifest file."); DECLARE_MESSAGE(AddPortSucceeded, (), "", "Succeeded in adding ports to vcpkg.json file."); + DECLARE_MESSAGE(AddRecurseOption, + (), + "", + "If you are sure you want to remove them, run the command with the --recurse option."); DECLARE_MESSAGE(AddTripletExpressionNotAllowed, (msg::package_name, msg::triplet), "", @@ -727,8 +735,8 @@ namespace vcpkg (msg::path), "", "Could not deduce nuget id and version from filename: {path}"); - DECLARE_MESSAGE(CreateFailureLogsDir, (msg::path), "", "Creating failure logs output directory {path}."); DECLARE_MESSAGE(CreatedNuGetPackage, (msg::path), "", "Created nupkg: \"{path}\""); + DECLARE_MESSAGE(CreateFailureLogsDir, (msg::path), "", "Creating failure logs output directory {path}."); DECLARE_MESSAGE(CurlReportedUnexpectedResults, (msg::command_line, msg::actual), "{command_line} is the command line to call curl.exe, {actual} is the console output " @@ -778,6 +786,7 @@ namespace vcpkg DECLARE_MESSAGE(EmailVcpkgTeam, (msg::url), "", "Send an email to {url} with any feedback."); DECLARE_MESSAGE(EmptyArg, (msg::option), "", "The option --{option} must be passed a non-empty argument."); DECLARE_MESSAGE(EmptyLicenseExpression, (), "", "SPDX license expression was empty."); + DECLARE_MESSAGE(EmptyRemovePlan, (), "", "Remove plan cannot be empty"); DECLARE_MESSAGE(EnvStrFailedToExtract, (), "", "could not expand the environment string:"); DECLARE_MESSAGE(ErrorDetectingCompilerInfo, (msg::path), @@ -860,42 +869,53 @@ namespace vcpkg "expected '{expected}' here"); DECLARE_MESSAGE(ExpectedFailOrSkip, (), "", "expected 'fail', 'skip', or 'pass' here"); DECLARE_MESSAGE(ExpectedPortName, (), "", "expected a port name here"); + DECLARE_MESSAGE(ExpectedStatusField, (), "", "Expected 'status' field in status paragraph"); DECLARE_MESSAGE(ExpectedTripletName, (), "", "expected a triplet name here"); DECLARE_MESSAGE(ExpectedValueForOption, (msg::option), "", "expected value after --{option}."); DECLARE_MESSAGE(ExportingPackage, (msg::package_name), "", "Exporting {package_name}..."); DECLARE_MESSAGE(ExtendedDocumentationAtUrl, (msg::url), "", "Extended documentation available at '{url}'."); + DECLARE_MESSAGE(FailedSymlinkStatus, + (msg::path, msg::error_msg), + "", + "failed: symlink_status({path}): {error_msg}"); DECLARE_MESSAGE(FailedToExtract, (msg::path), "", "Failed to extract \"{path}\":"); + DECLARE_MESSAGE(FailedToFindPortFeature, (msg::feature, msg::spec), "", "Could not find {feature} in {spec}."); DECLARE_MESSAGE(FailedToFormatMissingFile, (), "", "No files to format.\nPlease pass either --all, or the explicit files to format or convert."); + DECLARE_MESSAGE(FailedToLoadInstalledManifest, + (msg::spec), + "", + "The control or mnaifest file for {spec} could not be loaded due to the following error. Please " + "remove {spec} and re-attempt."); + DECLARE_MESSAGE(FailedToLoadPort, + (msg::package_name, msg::path), + "", + "Failed to load port {package_name} from {path}"); + DECLARE_MESSAGE(FailedToLoadPortFrom, (msg::path), "", "Failed to load port from {path}"); + DECLARE_MESSAGE(FailedToLocateSpec, (msg::spec), "", "Failed to locate spec in graph: {spec}"); + DECLARE_MESSAGE(FailedToObtainDependencyVersion, (), "", "Cannot find desired dependency version."); DECLARE_MESSAGE(FailedToObtainLocalPortGitSha, (), "", "Failed to obtain git SHAs for local ports."); + DECLARE_MESSAGE(FailedToObtainPackageVersion, (), "", "Cannot find desired package version."); 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(FailedToParseSerializedBinParagraph, (msg::error_msg), "'{error_msg}' is the error message for failing to parse the Binary Paragraph.", "[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:"); - DECLARE_MESSAGE(FailedToFindPortFeature, (msg::feature, msg::spec), "", "Could not find {feature} in {spec}."); - DECLARE_MESSAGE(FailedToLocateSpec, (msg::spec), "", "Failed to locate spec in graph: {spec}"); - DECLARE_MESSAGE(FailedToLoadInstalledManifest, - (msg::spec), - "", - "The control or mnaifest file for {spec} could not be loaded due to the following error. Please " - "remove {spec} and re-attempt."); - DECLARE_MESSAGE(FailedToObtainDependencyVersion, (), "", "Cannot find desired dependency version."); - DECLARE_MESSAGE(FailedToObtainPackageVersion, (), "", "Cannot find desired package version."); - 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(FailedToRemoveDirectory, (msg::path, msg::error_msg), "", "failed:remove({path}): {error_msg}"); DECLARE_MESSAGE(FailedToRunToolToDetermineVersion, (msg::tool_name, msg::path), "Additional information, such as the command line output, if any, will be appended on " @@ -910,6 +930,7 @@ namespace vcpkg "One or more {vendor} credential providers failed to authenticate. See '{url}' for more details " "on how to provide credentials."); DECLARE_MESSAGE(FeedbackAppreciated, (), "", "Thank you for your feedback!"); + DECLARE_MESSAGE(FileNotFound, (msg::path), "", "{path}: file not found"); DECLARE_MESSAGE(FishCompletion, (msg::path), "", "vcpkg fish completion is already added at \"{path}\"."); DECLARE_MESSAGE(FollowingPackagesMissingControl, (), @@ -1011,6 +1032,7 @@ namespace vcpkg "", "Could not create a registry at {path} because this is not a git repository root.\nUse `git init " "{command_line}` to create a git repository in this folder."); + DECLARE_MESSAGE(InsertedNullParagraph, (), "", "Inserted null paragraph"); DECLARE_MESSAGE(InstalledPackages, (), "", "The following packages are already installed:"); DECLARE_MESSAGE(InstalledRequestedPackages, (), "", "All requested packages are currently installed."); DECLARE_MESSAGE(InstallingFromLocation, @@ -1108,6 +1130,7 @@ namespace vcpkg (msg::value, msg::path), "'{value}' is a list of invalid characters. I.e. \\/:*?<>|", "Filename cannot contain invalid chars {value}, but was {path}"); + DECLARE_MESSAGE(InvalidFileType, (msg::path), "", "{path}: cannot handle file type"); DECLARE_MESSAGE(InvalidFormatString, (msg::actual), "{actual} is the provided format string", @@ -1117,6 +1140,7 @@ 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(InvalidOptionForRemove, (), "", "'remove' accepts either libraries or '--outdated'"); DECLARE_MESSAGE(IrregularFile, (msg::path), "", "path was not a regular file: {path}"); DECLARE_MESSAGE(JsonErrorMustBeAnObject, (msg::path), "", "Expected \"{path}\" to be an object."); DECLARE_MESSAGE(JsonSwitch, (), "", "(Experimental) Request JSON output."); @@ -1222,6 +1246,10 @@ namespace vcpkg "rather than by localization."); DECLARE_MESSAGE(ManifestFormatCompleted, (), "", "Succeeded in formatting the manifest files."); DECLARE_MESSAGE(MismatchedFiles, (), "", "file to store does not match hash"); + DECLARE_MESSAGE(MismatchedNames, + (msg::package_name, msg::actual), + "{actual} is the port name found", + "names did not match: '{package_name}' != '{actual}'"); DECLARE_MESSAGE(Missing7zHeader, (), "", "Unable to find 7z header."); DECLARE_MESSAGE(MissingArgFormatManifest, (), @@ -1278,6 +1306,7 @@ namespace vcpkg "The name 'search' is the name of a command that is not localized.", "No packages are installed. Did you mean `search`?"); DECLARE_MESSAGE(NoLocalizationForMessages, (), "", "No localized messages for the following: "); + DECLARE_MESSAGE(NoOutdatedPackages, (), "", "There are no outdated packages."); DECLARE_MESSAGE(NoRegistryForPort, (msg::package_name), "", "no registry configured for port {package_name}"); DECLARE_MESSAGE(NugetPackageFileSucceededButCreationFailed, (msg::path), @@ -1290,6 +1319,8 @@ namespace vcpkg "{value} is a command line option.", "--{value} requires --{option}"); DECLARE_MESSAGE(OriginalBinParagraphHeader, (), "", "\nOriginal Binary Paragraph"); + DECLARE_MESSAGE(OverlayPatchDir, (msg::path), "", "Overlay path \"{path}\" must exist and must be a directory."); + DECLARE_MESSAGE(PackageAlreadyRemoved, (msg::spec), "", "unable to remove package {spec}: already removed"); DECLARE_MESSAGE(PackageFailedtWhileExtracting, (msg::value, msg::path), "'{value}' is either a tool name or a package name.", @@ -1357,11 +1388,20 @@ namespace vcpkg (msg::tool_name, msg::exit_code), "The program's console output is appended after this.", "{tool_name} failed with exit code: ({exit_code})."); + DECLARE_MESSAGE(PurgeOptionConflict, (), "", "cannot specify both --no-purge and --purge."); DECLARE_MESSAGE(PushingVendorFailed, (msg::vendor, msg::path), "", "Pushing {vendor} to \"{path}\" failed. Use --debug for more information."); DECLARE_MESSAGE(RegistryCreated, (msg::path), "", "Successfully created registry at {path}"); + DECLARE_MESSAGE(RemoveDependencies, + (), + "", + "To remove dependencies in manifest mode, edit your manifest (vcpkg.json) and run 'install'."); + DECLARE_MESSAGE(RemovePackageConflict, + (msg::spec), + "", + "Another installed package matches the name of an unmatched request. Did you mean {spec}?"); DECLARE_MESSAGE(ReplaceSecretsError, (msg::error_msg), "", @@ -1647,45 +1687,4 @@ namespace vcpkg DECLARE_MESSAGE(WhileLookingForSpec, (msg::spec), "", "while looking for {spec}:"); DECLARE_MESSAGE(WindowsOnlyCommand, (), "", "This command only supports Windows."); DECLARE_MESSAGE(WroteNuGetPkgConfInfo, (msg::path), "", "Wrote NuGet package config information to {path}."); - DECLARE_MESSAGE(InsertedNullParagraph, (), "", "Inserted null paragraph"); - DECLARE_MESSAGE(ExpectedStatusField, (), "", "Expected 'status' field in status paragraph"); - DECLARE_MESSAGE(PackageAlreadyRemoved, (msg::spec), "", "unable to remove package {spec}: already removed"); - DECLARE_MESSAGE(FailedSymlinkStatus, - (msg::path, msg::error_msg), - "", - "failed: symlink_status({path}): {error_msg}"); - DECLARE_MESSAGE(FailedToRemoveDirectory, (msg::path, msg::error_msg), "", "failed:remove({path}): {error_msg}"); - DECLARE_MESSAGE(InvalidFileType, (msg::path), "", "{path}: cannot handle file type"); - DECLARE_MESSAGE(FileNotFound, (msg::path), "", "{path}: file not found"); - DECLARE_MESSAGE(InvalidOptionForRemove, (), "", "'remove' accepts either libraries or '--outdated'"); - DECLARE_MESSAGE(NoOutdatedPackages, (), "", "There are no outdated packages."); - DECLARE_MESSAGE(PurgeOptionConflict, (), "", "cannot specify both --no-purge and --purge."); - DECLARE_MESSAGE(EmptyRemovePlan, (), "", "Remove plan cannot be empty"); - DECLARE_MESSAGE(FailedToLoadPort, - (msg::package_name, msg::path), - "", - "Failed to load port {package_name} from {path}"); - DECLARE_MESSAGE(AdditionalPackagesToRemove, - (), - "", - "Additional packages (*) need to be removed to complete this operation."); - DECLARE_MESSAGE(AddRecurseOption, - (), - "", - "If you are sure you want to remove them, run the command with the --recurse option."); - DECLARE_MESSAGE(RemovePackageConflict, - (msg::spec), - "", - "Another installed package matches the name of an unmatched request. Did you mean {spec}?"); - DECLARE_MESSAGE(RemoveDependencies, - (), - "", - "To remove dependencies in manifest mode, edit your manifest (vcpkg.json) and run 'install'."); - DECLARE_MESSAGE(OverlayPatchDir, (msg::path), "", "Overlay path \"{path}\" must exist and must be a directory."); - DECLARE_MESSAGE(MismatchedNames, - (msg::package_name, msg::actual), - "{actual} is the port name found", - "names did not match: '{package_name}' != '{actual}'"); - DECLARE_MESSAGE(FailedToLoadPortFrom, (msg::path), "", "Failed to load port from {path}"); - } diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 97ab3e9dee..706602bfa4 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -386,8 +386,10 @@ namespace vcpkg REGISTER_MESSAGE(AddCommandFirstArg); REGISTER_MESSAGE(AddFirstArgument); REGISTER_MESSAGE(AddingCompletionEntry); + REGISTER_MESSAGE(AdditionalPackagesToRemove); REGISTER_MESSAGE(AddPortRequiresManifest); REGISTER_MESSAGE(AddPortSucceeded); + REGISTER_MESSAGE(AddRecurseOption); REGISTER_MESSAGE(AddTripletExpressionNotAllowed); REGISTER_MESSAGE(AddVersionAddedVersionToFile); REGISTER_MESSAGE(AddVersionCommitChangesReminder); @@ -466,8 +468,8 @@ namespace vcpkg REGISTER_MESSAGE(CMakeToolChainFile); REGISTER_MESSAGE(CommandFailed); REGISTER_MESSAGE(CompressFolderFailed); - REGISTER_MESSAGE(ConstraintViolation); REGISTER_MESSAGE(ConflictingValuesForOption); + REGISTER_MESSAGE(ConstraintViolation); REGISTER_MESSAGE(ControlAndManifestFilesPresent); REGISTER_MESSAGE(CopyrightIsDir); REGISTER_MESSAGE(CorruptedDatabase); @@ -494,6 +496,7 @@ namespace vcpkg REGISTER_MESSAGE(EmailVcpkgTeam); REGISTER_MESSAGE(EmptyArg); REGISTER_MESSAGE(EmptyLicenseExpression); + REGISTER_MESSAGE(EmptyRemovePlan); REGISTER_MESSAGE(EnvStrFailedToExtract); REGISTER_MESSAGE(ErrorDetectingCompilerInfo); REGISTER_MESSAGE(ErrorIndividualPackagesUnsupported); @@ -522,14 +525,18 @@ namespace vcpkg REGISTER_MESSAGE(ExpectedCharacterHere); REGISTER_MESSAGE(ExpectedFailOrSkip); REGISTER_MESSAGE(ExpectedPortName); + REGISTER_MESSAGE(ExpectedStatusField); REGISTER_MESSAGE(ExpectedTripletName); REGISTER_MESSAGE(ExpectedValueForOption); REGISTER_MESSAGE(ExportingPackage); REGISTER_MESSAGE(ExtendedDocumentationAtUrl); + REGISTER_MESSAGE(FailedSymlinkStatus); REGISTER_MESSAGE(FailedToExtract); REGISTER_MESSAGE(FailedToFindPortFeature); REGISTER_MESSAGE(FailedToFormatMissingFile); REGISTER_MESSAGE(FailedToLoadInstalledManifest); + REGISTER_MESSAGE(FailedToLoadPort); + REGISTER_MESSAGE(FailedToLoadPortFrom); REGISTER_MESSAGE(FailedToLocateSpec); REGISTER_MESSAGE(FailedToObtainDependencyVersion); REGISTER_MESSAGE(FailedToObtainLocalPortGitSha); @@ -543,12 +550,14 @@ namespace vcpkg REGISTER_MESSAGE(FailedToRead); REGISTER_MESSAGE(FailedToReadParagraph); REGISTER_MESSAGE(FailedToRemoveControl); + REGISTER_MESSAGE(FailedToRemoveDirectory); REGISTER_MESSAGE(FailedToRunToolToDetermineVersion); REGISTER_MESSAGE(FailedToStoreBackToMirror); REGISTER_MESSAGE(FailedToStoreBinaryCache); REGISTER_MESSAGE(FailedToWriteManifest); REGISTER_MESSAGE(FailedVendorAuthentication); REGISTER_MESSAGE(FeedbackAppreciated); + REGISTER_MESSAGE(FileNotFound); REGISTER_MESSAGE(FishCompletion); REGISTER_MESSAGE(FollowingPackagesMissingControl); REGISTER_MESSAGE(FollowingPackagesNotInstalled); @@ -595,6 +604,7 @@ namespace vcpkg REGISTER_MESSAGE(IncorrectNumberOfArgs); REGISTER_MESSAGE(InfoSetEnvVar); REGISTER_MESSAGE(InitRegistryFailedNoRepo); + REGISTER_MESSAGE(InsertedNullParagraph); REGISTER_MESSAGE(InstalledPackages); REGISTER_MESSAGE(InstalledRequestedPackages); REGISTER_MESSAGE(InstallingFromLocation); @@ -625,8 +635,10 @@ namespace vcpkg REGISTER_MESSAGE(InvalidCommandArgSort); REGISTER_MESSAGE(InvalidCommitId); REGISTER_MESSAGE(InvalidFilename); + REGISTER_MESSAGE(InvalidFileType); REGISTER_MESSAGE(InvalidFormatString); REGISTER_MESSAGE(InvalidLinkage); + REGISTER_MESSAGE(InvalidOptionForRemove); REGISTER_MESSAGE(IrregularFile); REGISTER_MESSAGE(JsonErrorMustBeAnObject); REGISTER_MESSAGE(JsonSwitch); @@ -656,13 +668,14 @@ namespace vcpkg REGISTER_MESSAGE(LocalizedMessageMustNotEndWithNewline); REGISTER_MESSAGE(ManifestFormatCompleted); REGISTER_MESSAGE(MismatchedFiles); + REGISTER_MESSAGE(MismatchedNames); REGISTER_MESSAGE(Missing7zHeader); REGISTER_MESSAGE(MissingArgFormatManifest); REGISTER_MESSAGE(MissingDependency); REGISTER_MESSAGE(MissingExtension); REGISTER_MESSAGE(MissingOption); - REGISTER_MESSAGE(MissmatchedBinParagraphs); REGISTER_MESSAGE(MissingPortSuggestPullRequest); + REGISTER_MESSAGE(MissmatchedBinParagraphs); REGISTER_MESSAGE(MonoInstructions); REGISTER_MESSAGE(MsiexecFailedToExtract); REGISTER_MESSAGE(MultiArch); @@ -677,12 +690,15 @@ namespace vcpkg REGISTER_MESSAGE(NoCachedPackages); REGISTER_MESSAGE(NoInstalledPackages); REGISTER_MESSAGE(NoLocalizationForMessages); + REGISTER_MESSAGE(NoOutdatedPackages); REGISTER_MESSAGE(NoRegistryForPort); REGISTER_MESSAGE(NugetPackageFileSucceededButCreationFailed); REGISTER_MESSAGE(OptionMustBeInteger); REGISTER_MESSAGE(OptionRequired); REGISTER_MESSAGE(OptionRequiresOption); REGISTER_MESSAGE(OriginalBinParagraphHeader); + REGISTER_MESSAGE(OverlayPatchDir); + REGISTER_MESSAGE(PackageAlreadyRemoved); REGISTER_MESSAGE(PackageFailedtWhileExtracting); REGISTER_MESSAGE(PackageRootDir); REGISTER_MESSAGE(PackagesToInstall); @@ -710,8 +726,11 @@ namespace vcpkg REGISTER_MESSAGE(ProcessorArchitectureMissing); REGISTER_MESSAGE(ProcessorArchitectureW6432Malformed); REGISTER_MESSAGE(ProgramReturnedNonzeroExitCode); + REGISTER_MESSAGE(PurgeOptionConflict); REGISTER_MESSAGE(PushingVendorFailed); REGISTER_MESSAGE(RegistryCreated); + REGISTER_MESSAGE(RemoveDependencies); + REGISTER_MESSAGE(RemovePackageConflict); REGISTER_MESSAGE(ReplaceSecretsError); REGISTER_MESSAGE(RestoredPackage); REGISTER_MESSAGE(RestoredPackagesFromVendor); @@ -803,23 +822,4 @@ namespace vcpkg REGISTER_MESSAGE(WhileLookingForSpec); REGISTER_MESSAGE(WindowsOnlyCommand); REGISTER_MESSAGE(WroteNuGetPkgConfInfo); - REGISTER_MESSAGE(InsertedNullParagraph); - REGISTER_MESSAGE(ExpectedStatusField); - REGISTER_MESSAGE(PackageAlreadyRemoved); - REGISTER_MESSAGE(FailedSymlinkStatus); - REGISTER_MESSAGE(FailedToRemoveDirectory); - REGISTER_MESSAGE(InvalidFileType); - REGISTER_MESSAGE(FileNotFound); - REGISTER_MESSAGE(RemoveDependencies); - REGISTER_MESSAGE(InvalidOptionForRemove); - REGISTER_MESSAGE(NoOutdatedPackages); - REGISTER_MESSAGE(PurgeOptionConflict); - REGISTER_MESSAGE(EmptyRemovePlan); - REGISTER_MESSAGE(AdditionalPackagesToRemove); - REGISTER_MESSAGE(AddRecurseOption); - REGISTER_MESSAGE(RemovePackageConflict); - REGISTER_MESSAGE(FailedToLoadPort); - REGISTER_MESSAGE(OverlayPatchDir); - REGISTER_MESSAGE(MismatchedNames); - REGISTER_MESSAGE(FailedToLoadPortFrom); } From fdd22e04af9c0e685b22f6e962938424320da50b Mon Sep 17 00:00:00 2001 From: Javier Matos Denizac Date: Thu, 29 Sep 2022 11:33:33 -0700 Subject: [PATCH 06/11] Minor changes * improve message clarity * add explanation for InvalidOptionForRemove to avoid confusion amongst translators --- include/vcpkg/base/messages.h | 7 +++++-- locales/messages.en.json | 2 +- locales/messages.json | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 53b81615c4..b1a6d00cde 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -888,7 +888,7 @@ namespace vcpkg (msg::spec), "", "The control or mnaifest file for {spec} could not be loaded due to the following error. Please " - "remove {spec} and re-attempt."); + "remove {spec} and try again."); DECLARE_MESSAGE(FailedToLoadPort, (msg::package_name, msg::path), "", @@ -1140,7 +1140,10 @@ 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(InvalidOptionForRemove, (), "", "'remove' accepts either libraries or '--outdated'"); + DECLARE_MESSAGE(InvalidOptionForRemove, + (), + "'remove' is a command that should not be changed.", + "'remove' accepts either libraries or '--outdated'"); DECLARE_MESSAGE(IrregularFile, (msg::path), "", "path was not a regular file: {path}"); DECLARE_MESSAGE(JsonErrorMustBeAnObject, (msg::path), "", "Expected \"{path}\" to be an object."); DECLARE_MESSAGE(JsonSwitch, (), "", "(Experimental) Request JSON output."); diff --git a/locales/messages.en.json b/locales/messages.en.json index eec7b12b4e..85fcaac4ab 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -154,7 +154,7 @@ "FailedToExtract": "Failed to extract \"{path}\":", "FailedToFindPortFeature": "Could not find {feature} in {spec}.", "FailedToFormatMissingFile": "No files to format.\nPlease pass either --all, or the explicit files to format or convert.", - "FailedToLoadInstalledManifest": "The control or mnaifest file for {spec} could not be loaded due to the following error. Please remove {spec} and re-attempt.", + "FailedToLoadInstalledManifest": "The control or mnaifest file for {spec} could not be loaded due to the following error. Please remove {spec} and try again.", "FailedToLoadPort": "Failed to load port {package_name} from {path}", "FailedToLoadPortFrom": "Failed to load port from {path}", "FailedToLocateSpec": "Failed to locate spec in graph: {spec}", diff --git a/locales/messages.json b/locales/messages.json index f28a1b3c1e..f7bc9ede4b 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -265,7 +265,7 @@ "FailedToFindPortFeature": "Could not find {feature} in {spec}.", "_FailedToFindPortFeature.comment": "An example of {feature} is avisynthplus. An example of {spec} is zlib:x64-windows.", "FailedToFormatMissingFile": "No files to format.\nPlease pass either --all, or the explicit files to format or convert.", - "FailedToLoadInstalledManifest": "The control or mnaifest file for {spec} could not be loaded due to the following error. Please remove {spec} and re-attempt.", + "FailedToLoadInstalledManifest": "The control or mnaifest file for {spec} could not be loaded due to the following error. Please remove {spec} and try again.", "_FailedToLoadInstalledManifest.comment": "An example of {spec} is zlib:x64-windows.", "FailedToLoadPort": "Failed to load port {package_name} from {path}", "_FailedToLoadPort.comment": "An example of {package_name} is zlib. An example of {path} is /foo/bar.", @@ -431,6 +431,7 @@ "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.", "InvalidOptionForRemove": "'remove' accepts either libraries or '--outdated'", + "_InvalidOptionForRemove.comment": "'remove' is a command that should not be changed.", "IrregularFile": "path was not a regular file: {path}", "_IrregularFile.comment": "An example of {path} is /foo/bar.", "JsonErrorMustBeAnObject": "Expected \"{path}\" to be an object.", From 241a19e19557b695cc6eee571908a8b92d547a2c Mon Sep 17 00:00:00 2001 From: Javier Matos Denizac Date: Fri, 30 Sep 2022 11:24:01 -0700 Subject: [PATCH 07/11] Replaced "PurgeOptionConflict" with "MutuallyExclusiveOption" --- include/vcpkg/base/messages.h | 5 ++++- locales/messages.en.json | 2 +- locales/messages.json | 3 ++- src/vcpkg/base/messages.cpp | 2 +- src/vcpkg/remove.cpp | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index b1a6d00cde..675d3b832f 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -1391,7 +1391,10 @@ namespace vcpkg (msg::tool_name, msg::exit_code), "The program's console output is appended after this.", "{tool_name} failed with exit code: ({exit_code})."); - DECLARE_MESSAGE(PurgeOptionConflict, (), "", "cannot specify both --no-purge and --purge."); + DECLARE_MESSAGE(MutuallyExclusiveOption, + (msg::value, msg::option), + "{value} is a second {option} switch", + "--{value} can not be used with --{option}."); DECLARE_MESSAGE(PushingVendorFailed, (msg::vendor, msg::path), "", diff --git a/locales/messages.en.json b/locales/messages.en.json index 85fcaac4ab..3d8c04b9dd 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -302,6 +302,7 @@ "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:", "MultiArch": "Multi-Arch must be 'same' but was {option}", + "MutuallyExclusiveOption": "--{value} can not be used with --{option}.", "NavigateToNPS": "Please navigate to {url} in your preferred browser.", "NewConfigurationAlreadyExists": "Creating a manifest would overwrite a vcpkg-configuration.json at {path}.", "NewManifestAlreadyExists": "A manifest is already present at {path}.", @@ -350,7 +351,6 @@ "ProcessorArchitectureMissing": "The required environment variable %PROCESSOR_ARCHITECTURE% is missing.", "ProcessorArchitectureW6432Malformed": "Failed to parse %PROCESSOR_ARCHITEW6432% ({arch}) as a valid CPU architecture. Falling back to %PROCESSOR_ARCHITECTURE%.", "ProgramReturnedNonzeroExitCode": "{tool_name} failed with exit code: ({exit_code}).", - "PurgeOptionConflict": "cannot specify both --no-purge and --purge.", "PushingVendorFailed": "Pushing {vendor} to \"{path}\" failed. Use --debug for more information.", "RegistryCreated": "Successfully created registry at {path}", "RemoveDependencies": "To remove dependencies in manifest mode, edit your manifest (vcpkg.json) and run 'install'.", diff --git a/locales/messages.json b/locales/messages.json index f7bc9ede4b..c2f82fbf81 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -495,6 +495,8 @@ "_MsiexecFailedToExtract.comment": "An example of {path} is /foo/bar. An example of {exit_code} is 127.", "MultiArch": "Multi-Arch must be 'same' but was {option}", "_MultiArch.comment": "An example of {option} is editable.", + "MutuallyExclusiveOption": "--{value} can not be used with --{option}.", + "_MutuallyExclusiveOption.comment": "{value} is a second {option} switch An example of {option} is editable.", "NavigateToNPS": "Please navigate to {url} in your preferred browser.", "_NavigateToNPS.comment": "An example of {url} is https://github.com/microsoft/vcpkg.", "NewConfigurationAlreadyExists": "Creating a manifest would overwrite a vcpkg-configuration.json at {path}.", @@ -569,7 +571,6 @@ "_ProcessorArchitectureW6432Malformed.comment": "An example of {arch} is x64.", "ProgramReturnedNonzeroExitCode": "{tool_name} failed with exit code: ({exit_code}).", "_ProgramReturnedNonzeroExitCode.comment": "The program's console output is appended after this. An example of {tool_name} is aria2. An example of {exit_code} is 127.", - "PurgeOptionConflict": "cannot specify both --no-purge and --purge.", "PushingVendorFailed": "Pushing {vendor} to \"{path}\" failed. Use --debug for more information.", "_PushingVendorFailed.comment": "An example of {vendor} is Azure. An example of {path} is /foo/bar.", "RegistryCreated": "Successfully created registry at {path}", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 706602bfa4..83be76b1b5 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -726,7 +726,7 @@ namespace vcpkg REGISTER_MESSAGE(ProcessorArchitectureMissing); REGISTER_MESSAGE(ProcessorArchitectureW6432Malformed); REGISTER_MESSAGE(ProgramReturnedNonzeroExitCode); - REGISTER_MESSAGE(PurgeOptionConflict); + REGISTER_MESSAGE(MutuallyExclusiveOption); REGISTER_MESSAGE(PushingVendorFailed); REGISTER_MESSAGE(RegistryCreated); REGISTER_MESSAGE(RemoveDependencies); diff --git a/src/vcpkg/remove.cpp b/src/vcpkg/remove.cpp index f5c06c1193..dbb98eae41 100644 --- a/src/vcpkg/remove.cpp +++ b/src/vcpkg/remove.cpp @@ -234,7 +234,7 @@ namespace vcpkg::Remove const bool no_purge = Util::Sets::contains(options.switches, OPTION_NO_PURGE); if (no_purge && Util::Sets::contains(options.switches, OPTION_PURGE)) { - msg::println_error(msgPurgeOptionConflict); + msg::println_error(msgMutuallyExclusiveOption, msg::value = "no-purge", msg::option = "purge"); msg::write_unlocalized_text_to_stdout(Color::none, COMMAND_STRUCTURE.example_text); Checks::exit_fail(VCPKG_LINE_INFO); } From 94e50518f7bf7873c02725b5ee07d6692f8cbc4f Mon Sep 17 00:00:00 2001 From: Javier Matos Denizac Date: Tue, 4 Oct 2022 10:30:48 -0700 Subject: [PATCH 08/11] Response to feedback: * add overload for Checks::unreachable that takes a message * add function format_filesystem_call_error --- include/vcpkg/base/basic_checks.h | 1 + include/vcpkg/base/messages.h | 9 +-------- locales/messages.en.json | 6 +----- locales/messages.json | 9 +-------- src/vcpkg/base/checks.cpp | 10 ++++++++++ src/vcpkg/base/messages.cpp | 6 +----- src/vcpkg/remove.cpp | 27 +++++++++++++++++++++------ src/vcpkg/statusparagraphs.cpp | 6 +++++- 8 files changed, 41 insertions(+), 33 deletions(-) diff --git a/include/vcpkg/base/basic_checks.h b/include/vcpkg/base/basic_checks.h index b6df2dfdac..9ed23cb06c 100644 --- a/include/vcpkg/base/basic_checks.h +++ b/include/vcpkg/base/basic_checks.h @@ -14,6 +14,7 @@ namespace vcpkg::Checks // Indicate that an internal error has occurred and exit the tool. This should be used when invariants have been // broken. [[noreturn]] void unreachable(const LineInfo& line_info); + [[noreturn]] void unreachable(const LineInfo& line_info, StringView message); [[noreturn]] void exit_with_code(const LineInfo& line_info, const int exit_code); diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 675d3b832f..450f6e92d1 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -786,7 +786,6 @@ namespace vcpkg DECLARE_MESSAGE(EmailVcpkgTeam, (msg::url), "", "Send an email to {url} with any feedback."); DECLARE_MESSAGE(EmptyArg, (msg::option), "", "The option --{option} must be passed a non-empty argument."); DECLARE_MESSAGE(EmptyLicenseExpression, (), "", "SPDX license expression was empty."); - DECLARE_MESSAGE(EmptyRemovePlan, (), "", "Remove plan cannot be empty"); DECLARE_MESSAGE(EnvStrFailedToExtract, (), "", "could not expand the environment string:"); DECLARE_MESSAGE(ErrorDetectingCompilerInfo, (msg::path), @@ -874,10 +873,6 @@ namespace vcpkg DECLARE_MESSAGE(ExpectedValueForOption, (msg::option), "", "expected value after --{option}."); DECLARE_MESSAGE(ExportingPackage, (msg::package_name), "", "Exporting {package_name}..."); DECLARE_MESSAGE(ExtendedDocumentationAtUrl, (msg::url), "", "Extended documentation available at '{url}'."); - DECLARE_MESSAGE(FailedSymlinkStatus, - (msg::path, msg::error_msg), - "", - "failed: symlink_status({path}): {error_msg}"); DECLARE_MESSAGE(FailedToExtract, (msg::path), "", "Failed to extract \"{path}\":"); DECLARE_MESSAGE(FailedToFindPortFeature, (msg::feature, msg::spec), "", "Could not find {feature} in {spec}."); DECLARE_MESSAGE(FailedToFormatMissingFile, @@ -915,7 +910,6 @@ namespace vcpkg 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(FailedToRemoveDirectory, (msg::path, msg::error_msg), "", "failed:remove({path}): {error_msg}"); DECLARE_MESSAGE(FailedToRunToolToDetermineVersion, (msg::tool_name, msg::path), "Additional information, such as the command line output, if any, will be appended on " @@ -1032,7 +1026,6 @@ namespace vcpkg "", "Could not create a registry at {path} because this is not a git repository root.\nUse `git init " "{command_line}` to create a git repository in this folder."); - DECLARE_MESSAGE(InsertedNullParagraph, (), "", "Inserted null paragraph"); DECLARE_MESSAGE(InstalledPackages, (), "", "The following packages are already installed:"); DECLARE_MESSAGE(InstalledRequestedPackages, (), "", "All requested packages are currently installed."); DECLARE_MESSAGE(InstallingFromLocation, @@ -1130,7 +1123,6 @@ namespace vcpkg (msg::value, msg::path), "'{value}' is a list of invalid characters. I.e. \\/:*?<>|", "Filename cannot contain invalid chars {value}, but was {path}"); - DECLARE_MESSAGE(InvalidFileType, (msg::path), "", "{path}: cannot handle file type"); DECLARE_MESSAGE(InvalidFormatString, (msg::actual), "{actual} is the provided format string", @@ -1693,4 +1685,5 @@ namespace vcpkg DECLARE_MESSAGE(WhileLookingForSpec, (msg::spec), "", "while looking for {spec}:"); DECLARE_MESSAGE(WindowsOnlyCommand, (), "", "This command only supports Windows."); DECLARE_MESSAGE(WroteNuGetPkgConfInfo, (msg::path), "", "Wrote NuGet package config information to {path}."); + DECLARE_MESSAGE(FileSystemOperationFailed, (), "", "Filesystem operation failed:"); } diff --git a/locales/messages.en.json b/locales/messages.en.json index 3d8c04b9dd..b565a2c369 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -115,7 +115,6 @@ "EmailVcpkgTeam": "Send an email to {url} with any feedback.", "EmptyArg": "The option --{option} must be passed a non-empty argument.", "EmptyLicenseExpression": "SPDX license expression was empty.", - "EmptyRemovePlan": "Remove plan cannot be empty", "EnvStrFailedToExtract": "could not expand the environment string:", "ErrorDetectingCompilerInfo": "while detecting compiler information:\nThe log file content at \"{path}\" is:", "ErrorIndividualPackagesUnsupported": "In manifest mode, `vcpkg install` does not support individual package arguments.\nTo install additional packages, edit vcpkg.json and then run `vcpkg install` without any package arguments.", @@ -150,7 +149,6 @@ "ExpectedValueForOption": "expected value after --{option}.", "ExportingPackage": "Exporting {package_name}...", "ExtendedDocumentationAtUrl": "Extended documentation available at '{url}'.", - "FailedSymlinkStatus": "failed: symlink_status({path}): {error_msg}", "FailedToExtract": "Failed to extract \"{path}\":", "FailedToFindPortFeature": "Could not find {feature} in {spec}.", "FailedToFormatMissingFile": "No files to format.\nPlease pass either --all, or the explicit files to format or convert.", @@ -170,7 +168,6 @@ "FailedToRead": "Failed to read {path}: {error_msg}", "FailedToReadParagraph": "Failed to read paragraphs from {path}", "FailedToRemoveControl": "Failed to remove control file {path}", - "FailedToRemoveDirectory": "failed:remove({path}): {error_msg}", "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}", @@ -178,6 +175,7 @@ "FailedVendorAuthentication": "One or more {vendor} credential providers failed to authenticate. See '{url}' for more details on how to provide credentials.", "FeedbackAppreciated": "Thank you for your feedback!", "FileNotFound": "{path}: file not found", + "FileSystemOperationFailed": "Filesystem operation failed:", "FishCompletion": "vcpkg fish completion is already added at \"{path}\".", "FollowingPackagesMissingControl": "The following packages do not have a valid CONTROL or vcpkg.json:", "FollowingPackagesNotInstalled": "The following packages are not installed:", @@ -225,7 +223,6 @@ "IncorrectNumberOfArgs": "'{command_name}' requires '{expected}' arguments, but '{actual}' were provided.", "InfoSetEnvVar": "You can also set the environment variable '{env_var}' to your editor of choice.", "InitRegistryFailedNoRepo": "Could not create a registry at {path} because this is not a git repository root.\nUse `git init {command_line}` to create a git repository in this folder.", - "InsertedNullParagraph": "Inserted null paragraph", "InstallPackageInstruction": "With a project open, go to Tools->NuGet Package Manager->Package Manager Console and paste:\n Install-Package \"{value}\" -Source \"{path}\"", "InstallRootDir": "(Experimental) Specify the install root directory.", "InstallWithSystemManager": "You may be able to install this tool via your system package manager.", @@ -257,7 +254,6 @@ "InvalidBuildInfo": "Invalid BUILD_INFO file for package: {error_msg}", "InvalidCommandArgSort": "Value of --sort must be one of 'lexicographical', 'topological', 'reverse'.", "InvalidCommitId": "Invalid commit id {value}", - "InvalidFileType": "{path}: cannot handle file type", "InvalidFilename": "Filename cannot contain invalid chars {value}, but was {path}", "InvalidFormatString": "invalid format string: {actual}", "InvalidLinkage": "Invalid {system_name} linkage type: [{value}]", diff --git a/locales/messages.json b/locales/messages.json index c2f82fbf81..57b22ffbd9 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -203,7 +203,6 @@ "EmptyArg": "The option --{option} must be passed a non-empty argument.", "_EmptyArg.comment": "An example of {option} is editable.", "EmptyLicenseExpression": "SPDX license expression was empty.", - "EmptyRemovePlan": "Remove plan cannot be empty", "EnvStrFailedToExtract": "could not expand the environment string:", "ErrorDetectingCompilerInfo": "while detecting compiler information:\nThe log file content at \"{path}\" is:", "_ErrorDetectingCompilerInfo.comment": "An example of {path} is /foo/bar.", @@ -258,8 +257,6 @@ "_ExportingPackage.comment": "An example of {package_name} is zlib.", "ExtendedDocumentationAtUrl": "Extended documentation available at '{url}'.", "_ExtendedDocumentationAtUrl.comment": "An example of {url} is https://github.com/microsoft/vcpkg.", - "FailedSymlinkStatus": "failed: symlink_status({path}): {error_msg}", - "_FailedSymlinkStatus.comment": "An example of {path} is /foo/bar. An example of {error_msg} is File Not Found.", "FailedToExtract": "Failed to extract \"{path}\":", "_FailedToExtract.comment": "An example of {path} is /foo/bar.", "FailedToFindPortFeature": "Could not find {feature} in {spec}.", @@ -292,8 +289,6 @@ "_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.", - "FailedToRemoveDirectory": "failed:remove({path}): {error_msg}", - "_FailedToRemoveDirectory.comment": "An example of {path} is /foo/bar. An example of {error_msg} is File Not Found.", "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:", @@ -306,6 +301,7 @@ "FeedbackAppreciated": "Thank you for your feedback!", "FileNotFound": "{path}: file not found", "_FileNotFound.comment": "An example of {path} is /foo/bar.", + "FileSystemOperationFailed": "Filesystem operation failed:", "FishCompletion": "vcpkg fish completion is already added at \"{path}\".", "_FishCompletion.comment": "An example of {path} is /foo/bar.", "FollowingPackagesMissingControl": "The following packages do not have a valid CONTROL or vcpkg.json:", @@ -369,7 +365,6 @@ "_InfoSetEnvVar.comment": "In this context 'editor' means IDE An example of {env_var} is VCPKG_DEFAULT_TRIPLET.", "InitRegistryFailedNoRepo": "Could not create a registry at {path} because this is not a git repository root.\nUse `git init {command_line}` to create a git repository in this folder.", "_InitRegistryFailedNoRepo.comment": "An example of {path} is /foo/bar. An example of {command_line} is vcpkg install zlib.", - "InsertedNullParagraph": "Inserted null paragraph", "InstallPackageInstruction": "With a project open, go to Tools->NuGet Package Manager->Package Manager Console and paste:\n Install-Package \"{value}\" -Source \"{path}\"", "_InstallPackageInstruction.comment": "'{value}' is the nuget id. An example of {path} is /foo/bar.", "InstallRootDir": "(Experimental) Specify the install root directory.", @@ -422,8 +417,6 @@ "InvalidCommandArgSort": "Value of --sort must be one of 'lexicographical', 'topological', 'reverse'.", "InvalidCommitId": "Invalid commit id {value}", "_InvalidCommitId.comment": "'{value}' is a commit id.", - "InvalidFileType": "{path}: cannot handle file type", - "_InvalidFileType.comment": "An example of {path} is /foo/bar.", "InvalidFilename": "Filename cannot contain invalid chars {value}, but was {path}", "_InvalidFilename.comment": "'{value}' is a list of invalid characters. I.e. \\/:*?<>| An example of {path} is /foo/bar.", "InvalidFormatString": "invalid format string: {actual}", diff --git a/src/vcpkg/base/checks.cpp b/src/vcpkg/base/checks.cpp index ff5cf3fb20..36bf1ceacf 100644 --- a/src/vcpkg/base/checks.cpp +++ b/src/vcpkg/base/checks.cpp @@ -58,6 +58,16 @@ namespace vcpkg #endif } + [[noreturn]] void Checks::unreachable(const LineInfo& line_info, StringView message) + { + msg::write_unlocalized_text_to_stdout(Color::error, locale_invariant_lineinfo(line_info).append_raw(message)); +#ifndef NDEBUG + std::abort(); +#else + final_cleanup_and_exit(EXIT_FAILURE); +#endif + } + [[noreturn]] void Checks::exit_with_code(const LineInfo& line_info, const int exit_code) { Debug::println(locale_invariant_lineinfo(line_info)); diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 83be76b1b5..6c6d1c4ea4 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -496,7 +496,6 @@ namespace vcpkg REGISTER_MESSAGE(EmailVcpkgTeam); REGISTER_MESSAGE(EmptyArg); REGISTER_MESSAGE(EmptyLicenseExpression); - REGISTER_MESSAGE(EmptyRemovePlan); REGISTER_MESSAGE(EnvStrFailedToExtract); REGISTER_MESSAGE(ErrorDetectingCompilerInfo); REGISTER_MESSAGE(ErrorIndividualPackagesUnsupported); @@ -530,7 +529,6 @@ namespace vcpkg REGISTER_MESSAGE(ExpectedValueForOption); REGISTER_MESSAGE(ExportingPackage); REGISTER_MESSAGE(ExtendedDocumentationAtUrl); - REGISTER_MESSAGE(FailedSymlinkStatus); REGISTER_MESSAGE(FailedToExtract); REGISTER_MESSAGE(FailedToFindPortFeature); REGISTER_MESSAGE(FailedToFormatMissingFile); @@ -550,7 +548,6 @@ namespace vcpkg REGISTER_MESSAGE(FailedToRead); REGISTER_MESSAGE(FailedToReadParagraph); REGISTER_MESSAGE(FailedToRemoveControl); - REGISTER_MESSAGE(FailedToRemoveDirectory); REGISTER_MESSAGE(FailedToRunToolToDetermineVersion); REGISTER_MESSAGE(FailedToStoreBackToMirror); REGISTER_MESSAGE(FailedToStoreBinaryCache); @@ -604,7 +601,6 @@ namespace vcpkg REGISTER_MESSAGE(IncorrectNumberOfArgs); REGISTER_MESSAGE(InfoSetEnvVar); REGISTER_MESSAGE(InitRegistryFailedNoRepo); - REGISTER_MESSAGE(InsertedNullParagraph); REGISTER_MESSAGE(InstalledPackages); REGISTER_MESSAGE(InstalledRequestedPackages); REGISTER_MESSAGE(InstallingFromLocation); @@ -635,7 +631,6 @@ namespace vcpkg REGISTER_MESSAGE(InvalidCommandArgSort); REGISTER_MESSAGE(InvalidCommitId); REGISTER_MESSAGE(InvalidFilename); - REGISTER_MESSAGE(InvalidFileType); REGISTER_MESSAGE(InvalidFormatString); REGISTER_MESSAGE(InvalidLinkage); REGISTER_MESSAGE(InvalidOptionForRemove); @@ -822,4 +817,5 @@ namespace vcpkg REGISTER_MESSAGE(WhileLookingForSpec); REGISTER_MESSAGE(WindowsOnlyCommand); REGISTER_MESSAGE(WroteNuGetPkgConfInfo); + REGISTER_MESSAGE(FileSystemOperationFailed); } diff --git a/src/vcpkg/remove.cpp b/src/vcpkg/remove.cpp index dbb98eae41..3682187e71 100644 --- a/src/vcpkg/remove.cpp +++ b/src/vcpkg/remove.cpp @@ -19,6 +19,15 @@ namespace vcpkg::Remove REGISTER_MESSAGE(RemovingPackage); + LocalizedString format_filesystem_call_error(const std::error_code& ec, + StringView call_name, + std::initializer_list args) + { + auto arguments = args.size() == 0 ? "()" : "(\"" + Strings::join("\", \"", args.begin(), args.end()) + "\")"; + return msg::format(msgFileSystemOperationFailed) + .append_raw(fmt::format("\n{} {}:{}", call_name, arguments, ec.message())); + } + static void remove_package(Filesystem& fs, const InstalledPaths& installed, const PackageSpec& spec, @@ -51,7 +60,8 @@ namespace vcpkg::Remove const auto status = fs.symlink_status(target, ec); if (ec) { - msg::println_error(msgFailedSymlinkStatus, msg::path = target, msg::error_msg = ec.message()); + Checks::exit_with_message_and_line( + VCPKG_LINE_INFO, format_filesystem_call_error(ec, __func__, {target, spec.to_string()})); continue; } @@ -64,13 +74,13 @@ namespace vcpkg::Remove fs.remove(target, ec); if (ec) { - msg::println_error( - msgFailedToRemoveDirectory, msg::path = target, msg::error_msg = ec.message()); + Checks::exit_with_message_and_line( + VCPKG_LINE_INFO, format_filesystem_call_error(ec, __func__, {target, spec.to_string()})); } } else if (vcpkg::exists(status)) { - msg::println_warning(msgInvalidFileType, msg::path = target); + Checks::unreachable(VCPKG_LINE_INFO, fmt::format("\"{}\": cannot handle file type", target)); } else { @@ -87,7 +97,8 @@ namespace vcpkg::Remove fs.remove(*b, ec); if (ec) { - msg::write_unlocalized_text_to_stdout(Color::error, ec.message()); + Checks::exit_with_message_and_line(VCPKG_LINE_INFO, + format_filesystem_call_error(ec, __func__, {*b})); } } } @@ -244,7 +255,11 @@ namespace vcpkg::Remove const bool dry_run = Util::Sets::contains(options.switches, OPTION_DRY_RUN); const std::vector remove_plan = create_remove_plan(specs, status_db); - Checks::msg_check_exit(VCPKG_LINE_INFO, !remove_plan.empty(), msgEmptyRemovePlan); + + if (remove_plan.empty()) + { + Checks::unreachable(VCPKG_LINE_INFO, "Remove plan cannot be empty"); + } std::map> group_by_plan_type; Util::group_by(remove_plan, &group_by_plan_type, [](const RemovePlanAction& p) { return p.plan_type; }); diff --git a/src/vcpkg/statusparagraphs.cpp b/src/vcpkg/statusparagraphs.cpp index f92fad0a11..9e5d774092 100644 --- a/src/vcpkg/statusparagraphs.cpp +++ b/src/vcpkg/statusparagraphs.cpp @@ -124,7 +124,11 @@ namespace vcpkg StatusParagraphs::iterator StatusParagraphs::insert(std::unique_ptr pgh) { - Checks::msg_check_exit(VCPKG_LINE_INFO, pgh != nullptr, msgInsertedNullParagraph); + if (pgh == nullptr) + { + Checks::unreachable(VCPKG_LINE_INFO, "Inserted null paragraph"); + } + const PackageSpec& spec = pgh->package.spec; const auto ptr = find(spec.name(), spec.triplet(), pgh->package.feature); if (ptr == end()) From 3b4a2ca12ef6b9771258d54f8e1b63ada562e61a Mon Sep 17 00:00:00 2001 From: Javier Matos Denizac Date: Tue, 4 Oct 2022 12:09:27 -0700 Subject: [PATCH 09/11] minor change --- src/vcpkg/remove.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vcpkg/remove.cpp b/src/vcpkg/remove.cpp index 3682187e71..b7f1954866 100644 --- a/src/vcpkg/remove.cpp +++ b/src/vcpkg/remove.cpp @@ -19,9 +19,9 @@ namespace vcpkg::Remove REGISTER_MESSAGE(RemovingPackage); - LocalizedString format_filesystem_call_error(const std::error_code& ec, - StringView call_name, - std::initializer_list args) + static LocalizedString format_filesystem_call_error(const std::error_code& ec, + StringView call_name, + std::initializer_list args) { auto arguments = args.size() == 0 ? "()" : "(\"" + Strings::join("\", \"", args.begin(), args.end()) + "\")"; return msg::format(msgFileSystemOperationFailed) From 8179e8381b277572a28bed4a0065de1ff63ef70b Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Tue, 4 Oct 2022 12:52:14 -0700 Subject: [PATCH 10/11] Extract function format_filesystem_call_error for use by other callers. --- include/vcpkg/base/files.h | 11 ++++++++--- src/vcpkg/base/files.cpp | 12 ++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/vcpkg/base/files.h b/include/vcpkg/base/files.h index 09f0b1395e..305f7a33aa 100644 --- a/include/vcpkg/base/files.h +++ b/include/vcpkg/base/files.h @@ -4,12 +4,15 @@ #include #include +#include +#include #include #include #include #include +#include #include #include @@ -21,6 +24,11 @@ namespace vcpkg { + LocalizedString format_filesystem_call_error(LineInfo li, + const std::error_code& ec, + StringView call_name, + std::initializer_list args); + struct IgnoreErrors { operator std::error_code&() { return ec; } @@ -117,10 +125,7 @@ namespace vcpkg inline bool is_regular_file(FileType s) { return s == FileType::regular; } inline bool is_directory(FileType s) { return s == FileType::directory; } inline bool exists(FileType s) { return s != FileType::not_found && s != FileType::none; } -} -namespace vcpkg -{ struct FilePointer { protected: diff --git a/src/vcpkg/base/files.cpp b/src/vcpkg/base/files.cpp index 1c90e3b3ad..c3d311afa4 100644 --- a/src/vcpkg/base/files.cpp +++ b/src/vcpkg/base/files.cpp @@ -73,8 +73,7 @@ namespace StringView call_name, std::initializer_list args) { - auto arguments = args.size() == 0 ? "()" : "(\"" + Strings::join("\", \"", args.begin(), args.end()) + "\")"; - Checks::exit_with_message_and_line(li, Strings::concat(call_name, arguments, ": ", ec.message())); + Checks::msg_exit_with_message(li, format_filesystem_call_error(li, ec, call_name, args)); } #if defined(_WIN32) @@ -959,6 +958,15 @@ namespace namespace vcpkg { + LocalizedString format_filesystem_call_error(LineInfo li, + const std::error_code& ec, + StringView call_name, + std::initializer_list args) + { + auto arguments = args.size() == 0 ? "()" : "(\"" + Strings::join("\", \"", args.begin(), args.end()) + "\")"; + return LocalizedString::from_raw(Strings::concat(call_name, arguments, ": ", ec.message()))); + } + std::string Path::generic_u8string() const { #if defined(_WIN32) From 37a91afdf59fa8e63bb544c15faf55c7b8825559 Mon Sep 17 00:00:00 2001 From: Javier Matos Denizac Date: Tue, 4 Oct 2022 13:04:19 -0700 Subject: [PATCH 11/11] moved format_filesystem_call_error to files.cpp --- include/vcpkg/base/files.h | 3 +-- src/vcpkg/base/files.cpp | 7 +++---- src/vcpkg/remove.cpp | 19 +++---------------- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/include/vcpkg/base/files.h b/include/vcpkg/base/files.h index 305f7a33aa..fb56d8f3fb 100644 --- a/include/vcpkg/base/files.h +++ b/include/vcpkg/base/files.h @@ -24,8 +24,7 @@ namespace vcpkg { - LocalizedString format_filesystem_call_error(LineInfo li, - const std::error_code& ec, + LocalizedString format_filesystem_call_error(const std::error_code& ec, StringView call_name, std::initializer_list args); diff --git a/src/vcpkg/base/files.cpp b/src/vcpkg/base/files.cpp index c3d311afa4..565fdc741d 100644 --- a/src/vcpkg/base/files.cpp +++ b/src/vcpkg/base/files.cpp @@ -73,7 +73,7 @@ namespace StringView call_name, std::initializer_list args) { - Checks::msg_exit_with_message(li, format_filesystem_call_error(li, ec, call_name, args)); + Checks::msg_exit_with_message(li, format_filesystem_call_error(ec, call_name, args)); } #if defined(_WIN32) @@ -958,13 +958,12 @@ namespace namespace vcpkg { - LocalizedString format_filesystem_call_error(LineInfo li, - const std::error_code& ec, + LocalizedString format_filesystem_call_error(const std::error_code& ec, StringView call_name, std::initializer_list args) { auto arguments = args.size() == 0 ? "()" : "(\"" + Strings::join("\", \"", args.begin(), args.end()) + "\")"; - return LocalizedString::from_raw(Strings::concat(call_name, arguments, ": ", ec.message()))); + return LocalizedString::from_raw(Strings::concat(call_name, arguments, ": ", ec.message())); } std::string Path::generic_u8string() const diff --git a/src/vcpkg/remove.cpp b/src/vcpkg/remove.cpp index b7f1954866..9114ff7c73 100644 --- a/src/vcpkg/remove.cpp +++ b/src/vcpkg/remove.cpp @@ -18,16 +18,6 @@ namespace vcpkg::Remove using Update::OutdatedPackage; REGISTER_MESSAGE(RemovingPackage); - - static LocalizedString format_filesystem_call_error(const std::error_code& ec, - StringView call_name, - std::initializer_list args) - { - auto arguments = args.size() == 0 ? "()" : "(\"" + Strings::join("\", \"", args.begin(), args.end()) + "\")"; - return msg::format(msgFileSystemOperationFailed) - .append_raw(fmt::format("\n{} {}:{}", call_name, arguments, ec.message())); - } - static void remove_package(Filesystem& fs, const InstalledPaths& installed, const PackageSpec& spec, @@ -60,8 +50,7 @@ namespace vcpkg::Remove const auto status = fs.symlink_status(target, ec); if (ec) { - Checks::exit_with_message_and_line( - VCPKG_LINE_INFO, format_filesystem_call_error(ec, __func__, {target, spec.to_string()})); + msg::println_error(format_filesystem_call_error(ec, "symlink_status", {target})); continue; } @@ -74,8 +63,7 @@ namespace vcpkg::Remove fs.remove(target, ec); if (ec) { - Checks::exit_with_message_and_line( - VCPKG_LINE_INFO, format_filesystem_call_error(ec, __func__, {target, spec.to_string()})); + msg::println_error(format_filesystem_call_error(ec, "remove", {target})); } } else if (vcpkg::exists(status)) @@ -97,8 +85,7 @@ namespace vcpkg::Remove fs.remove(*b, ec); if (ec) { - Checks::exit_with_message_and_line(VCPKG_LINE_INFO, - format_filesystem_call_error(ec, __func__, {*b})); + msg::println_error(format_filesystem_call_error(ec, "remove", {*b})); } } }