Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localize edit command and binary caching #551

Merged
merged 10 commits into from
May 24, 2022
5 changes: 5 additions & 0 deletions locales/messages.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"CiBaselineUnexpectedPass": "PASSING, REMOVE FROM FAIL LIST: {spec} ({path}).",
"CmakeTargetsExcluded": "note: {count} additional targets are not displayed.",
"CommandFailed": "command:\n{command_line}\nfailed with the following results:",
"CompressFolderFailed": "Failed to compress folder '{path}', exit code: {exit_code}",
"CouldNotDeduceNugetIdAndVersion": "Could not deduce nuget id and version from filename: {path}",
"CurlReportedUnexpectedResults": "curl has reported unexpected results to vcpkg and vcpkg cannot continue.\nPlease review the following text for sensitive information and open an issue on the Microsoft/vcpkg GitHub to help fix this problem!\ncmd: {command_line}\n=== curl output ===\n{actual}\n=== end curl output ===",
"DownloadAvailable": "A downloadable copy of this tool is available and can be used by unsetting {env_var}.",
Expand All @@ -75,6 +76,7 @@
"DownloadingVcpkgCeBundleLatest": "Downloading latest vcpkg-ce bundle...",
"ElapsedForPackage": "Elapsed time to handle {spec}: {elapsed}",
"EmptyLicenseExpression": "SPDX license expression was empty.",
"EnvStrFailedToExtract": "could not expand the environment string:",
"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.",
"ErrorInvalidClassicModeOption": "The option --{option} is not supported in classic mode and no manifest was found.",
"ErrorInvalidManifestModeOption": "The option --{option} is not supported in manifest mode.",
Expand All @@ -88,6 +90,8 @@
"ErrorRequireBaseline": "this vcpkg instance requires a manifest with a specified baseline in order to interact with ports. Please add 'builtin-baseline' to the manifest or add a 'vcpkg-configuration.json' that redefines the default registry.",
"ErrorRequirePackagesList": "`vcpkg install` requires a list of packages to install in classic mode.",
"ErrorVcvarsUnsupported": "in triplet {triplet}: Use of Visual Studio's Developer Prompt is unsupported on non-Windows hosts.\nDefine 'VCPKG_CMAKE_SYSTEM_NAME' or 'VCPKG_CHAINLOAD_TOOLCHAIN_FILE' in the triplet file.",
"ErrorVsCodeNotFound": "Visual Studio Code was not found and the environment variable '{env_var}' is not set or invalid.",
"ErrorVsCodeNotFoundPathExamined": "The following paths were examined:",
"ExcludedPackage": "Excluded {spec}",
"ExpectedCharacterHere": "expected '{expected}' here",
"ExpectedFailOrSkip": "expected 'fail' or 'skip' here",
Expand All @@ -112,6 +116,7 @@
"HeaderOnlyUsage": "{package_name} is header-only and can be used from CMake via:",
"IllegalFeatures": "List of features is not allowed in this context",
"IllegalPlatformSpec": "Platform qualifier is not allowed in this context",
"InfoSetEnvVar": "You can also set the environment variable '{env_var}' to your editor of choice.",
"InstallWithSystemManager": "You may be able to install this tool via your system package manager.",
"InstallWithSystemManagerMono": "Ubuntu 18.04 users may need a newer version of mono, available at {url}.",
"InstallWithSystemManagerPkg": "You may be able to install this tool via your system package manager ({command_line}).",
Expand Down
8 changes: 8 additions & 0 deletions locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@
"_CmakeTargetsExcluded.comment": "An example of {count} is 42.",
"CommandFailed": "command:\n{command_line}\nfailed with the following results:",
"_CommandFailed.comment": "An example of {command_line} is vcpkg install zlib.",
"CompressFolderFailed": "Failed to compress folder '{path}', exit code: {exit_code}",
"_CompressFolderFailed.comment": "An example of {path} is /foo/bar. An example of {exit_code} is 127.",
"CouldNotDeduceNugetIdAndVersion": "Could not deduce nuget id and version from filename: {path}",
"_CouldNotDeduceNugetIdAndVersion.comment": "An example of {path} is /foo/bar.",
"CurlReportedUnexpectedResults": "curl has reported unexpected results to vcpkg and vcpkg cannot continue.\nPlease review the following text for sensitive information and open an issue on the Microsoft/vcpkg GitHub to help fix this problem!\ncmd: {command_line}\n=== curl output ===\n{actual}\n=== end curl output ===",
Expand All @@ -138,6 +140,7 @@
"ElapsedForPackage": "Elapsed time to handle {spec}: {elapsed}",
"_ElapsedForPackage.comment": "An example of {spec} is zlib:x64-windows. An example of {elapsed} is 3.532 min.",
"EmptyLicenseExpression": "SPDX license expression was empty.",
"EnvStrFailedToExtract": "could not expand the environment string:",
"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.",
"ErrorInvalidClassicModeOption": "The option --{option} is not supported in classic mode and no manifest was found.",
"_ErrorInvalidClassicModeOption.comment": "An example of {option} is editable.",
Expand All @@ -159,6 +162,9 @@
"ErrorRequirePackagesList": "`vcpkg install` requires a list of packages to install in classic mode.",
"ErrorVcvarsUnsupported": "in triplet {triplet}: Use of Visual Studio's Developer Prompt is unsupported on non-Windows hosts.\nDefine 'VCPKG_CMAKE_SYSTEM_NAME' or 'VCPKG_CHAINLOAD_TOOLCHAIN_FILE' in the triplet file.",
"_ErrorVcvarsUnsupported.comment": "An example of {triplet} is x64-windows.",
"ErrorVsCodeNotFound": "Visual Studio Code was not found and the environment variable '{env_var}' is not set or invalid.",
"_ErrorVsCodeNotFound.comment": "An example of {env_var} is VCPKG_DEFAULT_TRIPLET.",
"ErrorVsCodeNotFoundPathExamined": "The following paths were examined:",
"ExcludedPackage": "Excluded {spec}",
"_ExcludedPackage.comment": "An example of {spec} is zlib:x64-windows.",
"ExpectedCharacterHere": "expected '{expected}' here",
Expand Down Expand Up @@ -195,6 +201,8 @@
"_HeaderOnlyUsage.comment": "'header' refers to C/C++ .h files An example of {package_name} is zlib.",
"IllegalFeatures": "List of features is not allowed in this context",
"IllegalPlatformSpec": "Platform qualifier is not allowed in this context",
"InfoSetEnvVar": "You can also set the environment variable '{env_var}' to your editor of choice.",
"_InfoSetEnvVar.comment": "In this context 'editor' means IDE An example of {env_var} is VCPKG_DEFAULT_TRIPLET.",
"InstallWithSystemManager": "You may be able to install this tool via your system package manager.",
"InstallWithSystemManagerMono": "Ubuntu 18.04 users may need a newer version of mono, available at {url}.",
"_InstallWithSystemManagerMono.comment": "An example of {url} is https://github.com/microsoft/vcpkg.",
Expand Down
8 changes: 6 additions & 2 deletions src/vcpkg/binarycaching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ namespace
(msg::binary_source),
"",
"invalid argument: binary config '{binary_source}' requires 2 or 3 arguments");
DECLARE_AND_REGISTER_MESSAGE(CompressFolderFailed,
(msg::path, msg::exit_code),
"",
"Failed to compress folder '{path}', exit code: {exit_code}");

struct ConfigSegmentsParser : ParserBase
{
Expand Down Expand Up @@ -1087,8 +1091,8 @@ namespace
paths.get_filesystem(), paths.get_tool_cache(), paths.package_dir(spec), tmp_archive_path);
if (code != 0)
{
vcpkg::print2(
Color::warning, "Failed to compress folder '", paths.package_dir(spec), "', exit code: ", code);
vcpkg::msg::println_warning(
msgCompressFolderFailed, msg::path = paths.package_dir(spec), msg::exit_code = code);
return;
}

Expand Down
33 changes: 26 additions & 7 deletions src/vcpkg/commands.edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@

#include <limits.h>

namespace
{
using namespace vcpkg;

DECLARE_AND_REGISTER_MESSAGE(EnvStrFailedToExtract, (), "", "could not expand the environment string:");

DECLARE_AND_REGISTER_MESSAGE(
ErrorVsCodeNotFound,
(msg::env_var),
"",
"Visual Studio Code was not found and the environment variable '{env_var}' is not set or invalid.");

DECLARE_AND_REGISTER_MESSAGE(ErrorVsCodeNotFoundPathExamined, (), "", "The following paths were examined:");

DECLARE_AND_REGISTER_MESSAGE(InfoSetEnvVar,
(msg::env_var),
"In this context 'editor' means IDE",
"You can also set the environment variable '{env_var}' to your editor of choice.");
}

#if defined(_WIN32)
namespace
{
Expand Down Expand Up @@ -66,8 +86,8 @@ namespace
ExpandEnvironmentStringsW(widened.c_str(), &result[0], static_cast<unsigned long>(result.size() + 1));
if (required_size == 0)
{
vcpkg::print2(vcpkg::Color::error, "Error: could not expand the environment string:\n");
vcpkg::print2(vcpkg::Color::error, input);
msg::println_error(
msg::format(msgEnvStrFailedToExtract).append_raw('\n').append(LocalizedString::from_raw(input)));
vcpkg::Checks::exit_fail(VCPKG_LINE_INFO);
}

Expand Down Expand Up @@ -240,12 +260,11 @@ namespace vcpkg::Commands::Edit
const auto it = Util::find_if(candidate_paths, [&](const Path& p) { return fs.exists(p, IgnoreErrors{}); });
if (it == candidate_paths.cend())
{
print2(
Color::error,
"Error: Visual Studio Code was not found and the environment variable EDITOR is not set or invalid.\n");
print2("The following paths were examined:\n");
msg::println_error(msg::format(msgErrorVsCodeNotFound, msg::env_var = "EDITOR")
.append_raw('\n')
.append(msgErrorVsCodeNotFoundPathExamined));
print_paths(candidate_paths);
print2("You can also set the environmental variable EDITOR to your editor of choice.\n");
msg::println(msgInfoSetEnvVar, msg::env_var = "EDITOR");
Checks::exit_fail(VCPKG_LINE_INFO);
}

Expand Down