Fix integrate to always know its subcommands. (#1161)
This commit is contained in:
Родитель
95d864dc82
Коммит
6b2f36a769
|
@ -28,8 +28,8 @@ $privateCommands = @(
|
||||||
'portsdiff'
|
'portsdiff'
|
||||||
)
|
)
|
||||||
|
|
||||||
function getOptionsForPrefix($prefix, $commands) {
|
function getOptionsForPrefix([string]$prefix, $commands) {
|
||||||
($commands | Sort-Object | ? { $_.StartsWith($prefix) }) -join '`n'
|
($commands | Sort-Object | ? { $_.StartsWith($prefix.ToLowerInvariant()) }) -join '`n'
|
||||||
}
|
}
|
||||||
function arraysEqual($arr1, $arr2) {
|
function arraysEqual($arr1, $arr2) {
|
||||||
if ($arr1.Length -ne $arr2.Length) {
|
if ($arr1.Length -ne $arr2.Length) {
|
||||||
|
@ -48,6 +48,7 @@ $publicPrefixesToTest = @(
|
||||||
'in'
|
'in'
|
||||||
's'
|
's'
|
||||||
'rem'
|
'rem'
|
||||||
|
'rEm'
|
||||||
'h'
|
'h'
|
||||||
'upgra'
|
'upgra'
|
||||||
'e'
|
'e'
|
||||||
|
|
|
@ -1522,23 +1522,34 @@ DECLARE_MESSAGE(InstallWithSystemManagerPkg,
|
||||||
DECLARE_MESSAGE(IntegrateBashHelp,
|
DECLARE_MESSAGE(IntegrateBashHelp,
|
||||||
(),
|
(),
|
||||||
"'bash' is a terminal program which should be unlocalized.",
|
"'bash' is a terminal program which should be unlocalized.",
|
||||||
"Enable bash tab-completion.")
|
"Enable bash tab-completion. Non-Windows only.")
|
||||||
DECLARE_MESSAGE(IntegrateFishHelp,
|
DECLARE_MESSAGE(IntegrateFishHelp,
|
||||||
(),
|
(),
|
||||||
"'fish' is a terminal program which should be unlocalized.",
|
"'fish' is a terminal program which should be unlocalized.",
|
||||||
"Enable fish tab-completion.")
|
"Enable fish tab-completion. Non-Windows only.")
|
||||||
DECLARE_MESSAGE(IntegrateInstallHelpLinux, (), "", "Make installed packages available user-wide.")
|
DECLARE_MESSAGE(IntegrateInstallHelpLinux, (), "", "Make installed packages available user-wide.")
|
||||||
DECLARE_MESSAGE(IntegrateInstallHelpWindows,
|
DECLARE_MESSAGE(IntegrateInstallHelpWindows,
|
||||||
(),
|
(),
|
||||||
"",
|
"",
|
||||||
"Make installed packages available user-wide. Requires admin privileges on first use.")
|
"Make installed packages available user-wide. Requires admin privileges on first use.")
|
||||||
DECLARE_MESSAGE(IntegratePowerShellHelp, (), "", "Enable PowerShell tab-completion.")
|
DECLARE_MESSAGE(IntegrateNonWindowsOnly,
|
||||||
DECLARE_MESSAGE(IntegrateProjectHelp, (), "", "Generate a referencing NuGet package for individual VS project use.")
|
(msg::command_line),
|
||||||
|
"",
|
||||||
|
"{command_line} is non-Windows-only and not supported on this system.")
|
||||||
|
DECLARE_MESSAGE(IntegratePowerShellHelp, (), "", "Enable PowerShell tab-completion. Windows-only.")
|
||||||
|
DECLARE_MESSAGE(IntegrateProjectHelp,
|
||||||
|
(),
|
||||||
|
"",
|
||||||
|
"Generate a referencing NuGet package for individual Visual Studio project use. Windows-only.")
|
||||||
DECLARE_MESSAGE(IntegrateRemoveHelp, (), "", "Remove user-wide integration.")
|
DECLARE_MESSAGE(IntegrateRemoveHelp, (), "", "Remove user-wide integration.")
|
||||||
|
DECLARE_MESSAGE(IntegrateWindowsOnly,
|
||||||
|
(msg::command_line),
|
||||||
|
"",
|
||||||
|
"{command_line} is Windows-only and not supported on this system.")
|
||||||
DECLARE_MESSAGE(IntegrateZshHelp,
|
DECLARE_MESSAGE(IntegrateZshHelp,
|
||||||
(),
|
(),
|
||||||
"'zsh' is a terminal program which should be unlocalized.",
|
"'zsh' is a terminal program which should be unlocalized.",
|
||||||
"Enable zsh tab-completion.")
|
"Enable zsh tab-completion. Non-Windows only.")
|
||||||
DECLARE_MESSAGE(IntegrationFailedVS2015, (), "", "Integration was not applied for Visual Studio 2015.")
|
DECLARE_MESSAGE(IntegrationFailedVS2015, (), "", "Integration was not applied for Visual Studio 2015.")
|
||||||
DECLARE_MESSAGE(InternalCICommand,
|
DECLARE_MESSAGE(InternalCICommand,
|
||||||
(),
|
(),
|
||||||
|
|
|
@ -863,16 +863,20 @@
|
||||||
"_InstallingMavenFile.comment": "Printed after a filesystem operation error An example of {path} is /foo/bar.",
|
"_InstallingMavenFile.comment": "Printed after a filesystem operation error An example of {path} is /foo/bar.",
|
||||||
"InstallingPackage": "Installing {action_index}/{count} {spec}...",
|
"InstallingPackage": "Installing {action_index}/{count} {spec}...",
|
||||||
"_InstallingPackage.comment": "An example of {action_index} is 340. An example of {count} is 42. An example of {spec} is zlib:x64-windows.",
|
"_InstallingPackage.comment": "An example of {action_index} is 340. An example of {count} is 42. An example of {spec} is zlib:x64-windows.",
|
||||||
"IntegrateBashHelp": "Enable bash tab-completion.",
|
"IntegrateBashHelp": "Enable bash tab-completion. Non-Windows only.",
|
||||||
"_IntegrateBashHelp.comment": "'bash' is a terminal program which should be unlocalized.",
|
"_IntegrateBashHelp.comment": "'bash' is a terminal program which should be unlocalized.",
|
||||||
"IntegrateFishHelp": "Enable fish tab-completion.",
|
"IntegrateFishHelp": "Enable fish tab-completion. Non-Windows only.",
|
||||||
"_IntegrateFishHelp.comment": "'fish' is a terminal program which should be unlocalized.",
|
"_IntegrateFishHelp.comment": "'fish' is a terminal program which should be unlocalized.",
|
||||||
"IntegrateInstallHelpLinux": "Make installed packages available user-wide.",
|
"IntegrateInstallHelpLinux": "Make installed packages available user-wide.",
|
||||||
"IntegrateInstallHelpWindows": "Make installed packages available user-wide. Requires admin privileges on first use.",
|
"IntegrateInstallHelpWindows": "Make installed packages available user-wide. Requires admin privileges on first use.",
|
||||||
"IntegratePowerShellHelp": "Enable PowerShell tab-completion.",
|
"IntegrateNonWindowsOnly": "{command_line} is non-Windows-only and not supported on this system.",
|
||||||
"IntegrateProjectHelp": "Generate a referencing NuGet package for individual VS project use.",
|
"_IntegrateNonWindowsOnly.comment": "An example of {command_line} is vcpkg install zlib.",
|
||||||
|
"IntegratePowerShellHelp": "Enable PowerShell tab-completion. Windows-only.",
|
||||||
|
"IntegrateProjectHelp": "Generate a referencing NuGet package for individual Visual Studio project use. Windows-only.",
|
||||||
"IntegrateRemoveHelp": "Remove user-wide integration.",
|
"IntegrateRemoveHelp": "Remove user-wide integration.",
|
||||||
"IntegrateZshHelp": "Enable zsh tab-completion.",
|
"IntegrateWindowsOnly": "{command_line} is Windows-only and not supported on this system.",
|
||||||
|
"_IntegrateWindowsOnly.comment": "An example of {command_line} is vcpkg install zlib.",
|
||||||
|
"IntegrateZshHelp": "Enable zsh tab-completion. Non-Windows only.",
|
||||||
"_IntegrateZshHelp.comment": "'zsh' is a terminal program which should be unlocalized.",
|
"_IntegrateZshHelp.comment": "'zsh' is a terminal program which should be unlocalized.",
|
||||||
"IntegrationFailedVS2015": "Integration was not applied for Visual Studio 2015.",
|
"IntegrationFailedVS2015": "Integration was not applied for Visual Studio 2015.",
|
||||||
"InternalCICommand": "vcpkg ci is an internal command which will change incompatibly or be removed at any time.",
|
"InternalCICommand": "vcpkg ci is an internal command which will change incompatibly or be removed at any time.",
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace vcpkg::Commands::Autocomplete
|
||||||
const auto& command_name = command_arguments[0];
|
const auto& command_name = command_arguments[0];
|
||||||
|
|
||||||
// Handles vcpkg install package:<triplet>
|
// Handles vcpkg install package:<triplet>
|
||||||
if (command_name == "install")
|
if (Strings::case_insensitive_ascii_equals(command_name, "install"))
|
||||||
{
|
{
|
||||||
StringView last_arg = command_arguments.back();
|
StringView last_arg = command_arguments.back();
|
||||||
auto colon = Util::find(last_arg, ':');
|
auto colon = Util::find(last_arg, ':');
|
||||||
|
@ -140,7 +140,7 @@ namespace vcpkg::Commands::Autocomplete
|
||||||
|
|
||||||
for (auto&& command : COMMANDS)
|
for (auto&& command : COMMANDS)
|
||||||
{
|
{
|
||||||
if (command_name == command.name)
|
if (Strings::case_insensitive_ascii_equals(command_name, command.name))
|
||||||
{
|
{
|
||||||
StringView prefix = command_arguments.back();
|
StringView prefix = command_arguments.back();
|
||||||
std::vector<std::string> results;
|
std::vector<std::string> results;
|
||||||
|
@ -173,7 +173,8 @@ namespace vcpkg::Commands::Autocomplete
|
||||||
return !Strings::case_insensitive_ascii_starts_with(s, prefix);
|
return !Strings::case_insensitive_ascii_starts_with(s, prefix);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (command.name == "install" && results.size() == 1 && !is_option)
|
if (Strings::case_insensitive_ascii_equals(command.name, "install") && results.size() == 1 &&
|
||||||
|
!is_option)
|
||||||
{
|
{
|
||||||
const auto port_at_each_triplet =
|
const auto port_at_each_triplet =
|
||||||
combine_port_with_triplets(results[0], paths.get_triplet_db().available_triplets);
|
combine_port_with_triplets(results[0], paths.get_triplet_db().available_triplets);
|
||||||
|
|
|
@ -122,12 +122,8 @@ namespace vcpkg::Commands::Integrate
|
||||||
target_path,
|
target_path,
|
||||||
target_path);
|
target_path);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
static constexpr StringLiteral SystemTargetsShortcut = R"###(
|
||||||
static std::string create_system_targets_shortcut()
|
|
||||||
{
|
|
||||||
return R"###(
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<!-- version 1 -->
|
<!-- version 1 -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
@ -137,10 +133,7 @@ namespace vcpkg::Commands::Integrate
|
||||||
<Import Condition="'$(VCLibPackagePath)' != '' and Exists('$(VCLibPackagePath).targets')" Project="$(VCLibPackagePath).targets" />
|
<Import Condition="'$(VCLibPackagePath)' != '' and Exists('$(VCLibPackagePath).targets')" Project="$(VCLibPackagePath).targets" />
|
||||||
</Project>
|
</Project>
|
||||||
)###";
|
)###";
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
static std::string create_nuget_targets_file_contents(const Path& msbuild_vcpkg_targets_file)
|
static std::string create_nuget_targets_file_contents(const Path& msbuild_vcpkg_targets_file)
|
||||||
{
|
{
|
||||||
return fmt::format(R"###(
|
return fmt::format(R"###(
|
||||||
|
@ -154,7 +147,7 @@ namespace vcpkg::Commands::Integrate
|
||||||
msbuild_vcpkg_targets_file,
|
msbuild_vcpkg_targets_file,
|
||||||
msbuild_vcpkg_targets_file);
|
msbuild_vcpkg_targets_file);
|
||||||
}
|
}
|
||||||
#endif
|
#endif // ^^^ _WIN32
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
static constexpr StringLiteral NUGET_PROPS_FILE_CONTENTS = R"###(
|
static constexpr StringLiteral NUGET_PROPS_FILE_CONTENTS = R"###(
|
||||||
|
@ -164,7 +157,7 @@ namespace vcpkg::Commands::Integrate
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
)###";
|
)###";
|
||||||
#endif
|
#endif // ^^^ _WIN32
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
static std::string get_nuget_id(const Path& vcpkg_root_dir)
|
static std::string get_nuget_id(const Path& vcpkg_root_dir)
|
||||||
|
@ -176,10 +169,9 @@ namespace vcpkg::Commands::Integrate
|
||||||
// NuGet id cannot have invalid characters. We will only use alphanumeric and dot.
|
// NuGet id cannot have invalid characters. We will only use alphanumeric and dot.
|
||||||
Util::erase_remove_if(dir_id, [](char c) { return !isalnum(static_cast<unsigned char>(c)) && (c != '.'); });
|
Util::erase_remove_if(dir_id, [](char c) { return !isalnum(static_cast<unsigned char>(c)) && (c != '.'); });
|
||||||
|
|
||||||
const std::string nuget_id = "vcpkg." + dir_id;
|
return "vcpkg." + dir_id;
|
||||||
return nuget_id;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif // ^^^ _WIN32
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
static std::string create_nuspec_file_contents(const Path& vcpkg_root_dir,
|
static std::string create_nuspec_file_contents(const Path& vcpkg_root_dir,
|
||||||
|
@ -208,7 +200,7 @@ namespace vcpkg::Commands::Integrate
|
||||||
Strings::inplace_replace_all(content, "@VERSION@", nupkg_version);
|
Strings::inplace_replace_all(content, "@VERSION@", nupkg_version);
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // ^^^ _WIN32
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
enum class ElevationPromptChoice
|
enum class ElevationPromptChoice
|
||||||
|
@ -244,7 +236,7 @@ namespace vcpkg::Commands::Integrate
|
||||||
CloseHandle(sh_ex_info.hProcess);
|
CloseHandle(sh_ex_info.hProcess);
|
||||||
return ElevationPromptChoice::YES;
|
return ElevationPromptChoice::YES;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // ^^^ _WIN32
|
||||||
|
|
||||||
static constexpr StringLiteral vcpkg_path_txt = "vcpkg.path.txt";
|
static constexpr StringLiteral vcpkg_path_txt = "vcpkg.path.txt";
|
||||||
|
|
||||||
|
@ -291,7 +283,7 @@ namespace vcpkg::Commands::Integrate
|
||||||
|
|
||||||
const auto tmp_dir = fs.create_or_get_temp_directory(VCPKG_LINE_INFO);
|
const auto tmp_dir = fs.create_or_get_temp_directory(VCPKG_LINE_INFO);
|
||||||
const auto sys_src_path = tmp_dir / "vcpkg.system.targets";
|
const auto sys_src_path = tmp_dir / "vcpkg.system.targets";
|
||||||
fs.write_contents(sys_src_path, create_system_targets_shortcut(), VCPKG_LINE_INFO);
|
fs.write_contents(sys_src_path, SystemTargetsShortcut, VCPKG_LINE_INFO);
|
||||||
|
|
||||||
const std::string param = fmt::format(R"(/c "mkdir "{}" & copy "{}" "{}" /Y > nul")",
|
const std::string param = fmt::format(R"(/c "mkdir "{}" & copy "{}" "{}" /Y > nul")",
|
||||||
SYSTEM_WIDE_TARGETS_FILE.parent_path(),
|
SYSTEM_WIDE_TARGETS_FILE.parent_path(),
|
||||||
|
@ -308,7 +300,7 @@ namespace vcpkg::Commands::Integrate
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // ^^^ _WIN32
|
||||||
|
|
||||||
static void integrate_install(const VcpkgPaths& paths)
|
static void integrate_install(const VcpkgPaths& paths)
|
||||||
{
|
{
|
||||||
|
@ -337,7 +329,7 @@ namespace vcpkg::Commands::Integrate
|
||||||
}
|
}
|
||||||
|
|
||||||
message.append_raw("\n\n").append(msgAutomaticLinkingForMSBuildProjects);
|
message.append_raw("\n\n").append(msgAutomaticLinkingForMSBuildProjects);
|
||||||
#endif
|
#endif // ^^^ _WIN32
|
||||||
|
|
||||||
msg::println(Color::success, msgAppliedUserIntegration);
|
msg::println(Color::success, msgAppliedUserIntegration);
|
||||||
msg::println(message);
|
msg::println(message);
|
||||||
|
@ -351,7 +343,7 @@ namespace vcpkg::Commands::Integrate
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
was_deleted |= fs.remove(user_configuration_home / vcpkg_user_props, VCPKG_LINE_INFO);
|
was_deleted |= fs.remove(user_configuration_home / vcpkg_user_props, VCPKG_LINE_INFO);
|
||||||
was_deleted |= fs.remove(user_configuration_home / vcpkg_user_targets, VCPKG_LINE_INFO);
|
was_deleted |= fs.remove(user_configuration_home / vcpkg_user_targets, VCPKG_LINE_INFO);
|
||||||
#endif
|
#endif // ^^^ _WIN32
|
||||||
was_deleted |= fs.remove(user_configuration_home / vcpkg_path_txt, VCPKG_LINE_INFO);
|
was_deleted |= fs.remove(user_configuration_home / vcpkg_path_txt, VCPKG_LINE_INFO);
|
||||||
|
|
||||||
if (was_deleted)
|
if (was_deleted)
|
||||||
|
@ -366,9 +358,9 @@ namespace vcpkg::Commands::Integrate
|
||||||
Checks::exit_success(VCPKG_LINE_INFO);
|
Checks::exit_success(VCPKG_LINE_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(WIN32)
|
|
||||||
static void integrate_project(const VcpkgPaths& paths)
|
static void integrate_project(const VcpkgPaths& paths)
|
||||||
{
|
{
|
||||||
|
#if defined(WIN32)
|
||||||
auto& fs = paths.get_filesystem();
|
auto& fs = paths.get_filesystem();
|
||||||
|
|
||||||
const Path& nuget_exe = paths.get_tool_exe(Tools::NUGET, stdout_sink);
|
const Path& nuget_exe = paths.get_tool_exe(Tools::NUGET, stdout_sink);
|
||||||
|
@ -416,12 +408,16 @@ namespace vcpkg::Commands::Integrate
|
||||||
|
|
||||||
msg::println(msgInstallPackageInstruction, msg::value = nuget_id, msg::path = source_path);
|
msg::println(msgInstallPackageInstruction, msg::value = nuget_id, msg::path = source_path);
|
||||||
Checks::exit_success(VCPKG_LINE_INFO);
|
Checks::exit_success(VCPKG_LINE_INFO);
|
||||||
|
#else // ^^^ _WIN32 // !_WIN32 vvv
|
||||||
|
(void)paths;
|
||||||
|
Checks::msg_exit_with_error(
|
||||||
|
VCPKG_LINE_INFO, msgIntegrateWindowsOnly, msg::command_line = "vcpkg integrate project");
|
||||||
|
#endif // ^^^ !_WIN32
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
static void integrate_powershell(const VcpkgPaths& paths)
|
static void integrate_powershell(const VcpkgPaths& paths)
|
||||||
{
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
static constexpr StringLiteral TITLE = "PowerShell Tab-Completion";
|
static constexpr StringLiteral TITLE = "PowerShell Tab-Completion";
|
||||||
const auto script_path = paths.scripts / "addPoshVcpkgToPowershellProfile.ps1";
|
const auto script_path = paths.scripts / "addPoshVcpkgToPowershellProfile.ps1";
|
||||||
|
|
||||||
|
@ -442,10 +438,20 @@ namespace vcpkg::Commands::Integrate
|
||||||
}
|
}
|
||||||
|
|
||||||
Checks::exit_with_code(VCPKG_LINE_INFO, rc);
|
Checks::exit_with_code(VCPKG_LINE_INFO, rc);
|
||||||
|
#else // ^^^ _WIN32 // !_WIN32 vvv
|
||||||
|
(void)paths;
|
||||||
|
Checks::msg_exit_with_error(
|
||||||
|
VCPKG_LINE_INFO, msgIntegrateWindowsOnly, msg::command_line = "vcpkg integrate powershell");
|
||||||
|
#endif // ^^^ !_WIN32
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
static void integrate_bash(const VcpkgPaths& paths)
|
static void integrate_bash(const VcpkgPaths& paths)
|
||||||
{
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
(void)paths;
|
||||||
|
Checks::msg_exit_with_error(
|
||||||
|
VCPKG_LINE_INFO, msgIntegrateNonWindowsOnly, msg::command_line = "vcpkg integrate bash");
|
||||||
|
#else // ^^^ _WIN32 // !_WIN32 vvv
|
||||||
const auto home_path = get_environment_variable("HOME").value_or_exit(VCPKG_LINE_INFO);
|
const auto home_path = get_environment_variable("HOME").value_or_exit(VCPKG_LINE_INFO);
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
const auto bashrc_path = Path{home_path} / ".bash_profile";
|
const auto bashrc_path = Path{home_path} / ".bash_profile";
|
||||||
|
@ -473,10 +479,16 @@ namespace vcpkg::Commands::Integrate
|
||||||
bashrc_content.push_back('\n');
|
bashrc_content.push_back('\n');
|
||||||
fs.write_contents(bashrc_path, bashrc_content, VCPKG_LINE_INFO);
|
fs.write_contents(bashrc_path, bashrc_content, VCPKG_LINE_INFO);
|
||||||
Checks::exit_success(VCPKG_LINE_INFO);
|
Checks::exit_success(VCPKG_LINE_INFO);
|
||||||
|
#endif // ^^^ !_WIN32
|
||||||
}
|
}
|
||||||
|
|
||||||
static void integrate_zsh(const VcpkgPaths& paths)
|
static void integrate_zsh(const VcpkgPaths& paths)
|
||||||
{
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
(void)paths;
|
||||||
|
Checks::msg_exit_with_error(
|
||||||
|
VCPKG_LINE_INFO, msgIntegrateNonWindowsOnly, msg::command_line = "vcpkg integrate zsh");
|
||||||
|
#else // ^^^ _WIN32 // !_WIN32 vvv
|
||||||
const auto home_path = get_environment_variable("HOME").value_or_exit(VCPKG_LINE_INFO);
|
const auto home_path = get_environment_variable("HOME").value_or_exit(VCPKG_LINE_INFO);
|
||||||
const auto zshrc_path = Path{home_path} / ".zshrc";
|
const auto zshrc_path = Path{home_path} / ".zshrc";
|
||||||
|
|
||||||
|
@ -510,10 +522,16 @@ namespace vcpkg::Commands::Integrate
|
||||||
zshrc_content.push_back('\n');
|
zshrc_content.push_back('\n');
|
||||||
fs.write_contents(zshrc_path, zshrc_content, VCPKG_LINE_INFO);
|
fs.write_contents(zshrc_path, zshrc_content, VCPKG_LINE_INFO);
|
||||||
Checks::exit_success(VCPKG_LINE_INFO);
|
Checks::exit_success(VCPKG_LINE_INFO);
|
||||||
|
#endif // ^^^ !_WIN32
|
||||||
}
|
}
|
||||||
|
|
||||||
static void integrate_fish(const VcpkgPaths& paths)
|
static void integrate_fish(const VcpkgPaths& paths)
|
||||||
{
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
(void)paths;
|
||||||
|
Checks::msg_exit_with_error(
|
||||||
|
VCPKG_LINE_INFO, msgIntegrateNonWindowsOnly, msg::command_line = "vcpkg integrate x-fish");
|
||||||
|
#else // ^^^ _WIN32 // !_WIN32 vvv
|
||||||
Path fish_completions_path;
|
Path fish_completions_path;
|
||||||
const auto config_path = get_environment_variable("XDG_CONFIG_HOME");
|
const auto config_path = get_environment_variable("XDG_CONFIG_HOME");
|
||||||
if (config_path.has_value())
|
if (config_path.has_value())
|
||||||
|
@ -545,23 +563,24 @@ namespace vcpkg::Commands::Integrate
|
||||||
msg::println(msgAddingCompletionEntry, msg::path = fish_completions_path);
|
msg::println(msgAddingCompletionEntry, msg::path = fish_completions_path);
|
||||||
fs.create_symlink(completion_script_path, fish_completions_path, VCPKG_LINE_INFO);
|
fs.create_symlink(completion_script_path, fish_completions_path, VCPKG_LINE_INFO);
|
||||||
Checks::exit_success(VCPKG_LINE_INFO);
|
Checks::exit_success(VCPKG_LINE_INFO);
|
||||||
|
#endif // ^^^ !_WIN32
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void append_helpstring(HelpTableFormatter& table)
|
void append_helpstring(HelpTableFormatter& table)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
table.format("vcpkg integrate install", msg::format(msgIntegrateInstallHelpWindows));
|
table.format("vcpkg integrate install", msg::format(msgIntegrateInstallHelpWindows));
|
||||||
table.format("vcpkg integrate remove", msg::format(msgIntegrateRemoveHelp));
|
|
||||||
table.format("vcpkg integrate project", msg::format(msgIntegrateProjectHelp));
|
|
||||||
table.format("vcpkg integrate powershell", msg::format(msgIntegratePowerShellHelp));
|
|
||||||
#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
|
#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
|
||||||
table.format("vcpkg integrate install", msg::format(msgIntegrateInstallHelpLinux));
|
table.format("vcpkg integrate install", msg::format(msgIntegrateInstallHelpLinux));
|
||||||
table.format("vcpkg integrate remove", msg::format(msgIntegrateRemoveHelp));
|
|
||||||
table.format("vcpkg integrate bash", msg::format(msgIntegrateBashHelp));
|
|
||||||
table.format("vcpkg integrate zsh", msg::format(msgIntegrateZshHelp));
|
|
||||||
table.format("vcpkg integrate x-fish", msg::format(msgIntegrateFishHelp));
|
|
||||||
#endif // ^^^ !defined(_WIN32)
|
#endif // ^^^ !defined(_WIN32)
|
||||||
|
table.format("vcpkg integrate remove", msg::format(msgIntegrateRemoveHelp));
|
||||||
|
table.blank();
|
||||||
|
table.format("vcpkg integrate project", msg::format(msgIntegrateProjectHelp));
|
||||||
|
table.blank();
|
||||||
|
table.format("vcpkg integrate bash", msg::format(msgIntegrateBashHelp));
|
||||||
|
table.format("vcpkg integrate x-fish", msg::format(msgIntegrateFishHelp));
|
||||||
|
table.format("vcpkg integrate powershell", msg::format(msgIntegratePowerShellHelp));
|
||||||
|
table.format("vcpkg integrate zsh", msg::format(msgIntegrateZshHelp));
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalizedString get_helpstring()
|
LocalizedString get_helpstring()
|
||||||
|
@ -571,28 +590,24 @@ namespace vcpkg::Commands::Integrate
|
||||||
return msg::format(msgCommands).append_raw('\n').append_raw(table.m_str);
|
return msg::format(msgCommands).append_raw('\n').append_raw(table.m_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Subcommand
|
|
||||||
{
|
|
||||||
static constexpr StringLiteral INSTALL = "install";
|
static constexpr StringLiteral INSTALL = "install";
|
||||||
static constexpr StringLiteral REMOVE = "remove";
|
static constexpr StringLiteral REMOVE = "remove";
|
||||||
#if defined(_WIN32)
|
|
||||||
static constexpr StringLiteral PROJECT = "project";
|
static constexpr StringLiteral PROJECT = "project";
|
||||||
static constexpr StringLiteral POWERSHELL = "powershell";
|
static constexpr StringLiteral POWERSHELL = "powershell";
|
||||||
#endif // ^^^ _WIN32
|
|
||||||
static constexpr StringLiteral BASH = "bash";
|
static constexpr StringLiteral BASH = "bash";
|
||||||
static constexpr StringLiteral ZSH = "zsh";
|
static constexpr StringLiteral ZSH = "zsh";
|
||||||
static constexpr StringLiteral FISH = "x-fish";
|
static constexpr StringLiteral FISH = "x-fish";
|
||||||
}
|
|
||||||
|
|
||||||
static std::vector<std::string> valid_arguments(const VcpkgPaths&)
|
static std::vector<std::string> valid_arguments(const VcpkgPaths&)
|
||||||
{
|
{
|
||||||
|
// Note that help lists all supported args, but we only want to autocomplete the ones valid on this platform
|
||||||
return
|
return
|
||||||
{
|
{
|
||||||
Subcommand::INSTALL.to_string(), Subcommand::REMOVE.to_string(),
|
INSTALL.to_string(), REMOVE.to_string(),
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
Subcommand::PROJECT.to_string(), Subcommand::POWERSHELL.to_string(),
|
PROJECT.to_string(), POWERSHELL.to_string(),
|
||||||
#else
|
#else
|
||||||
Subcommand::BASH.to_string(), Subcommand::FISH.to_string(),
|
BASH.to_string(), FISH.to_string(), ZSH.to_string()
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -609,37 +624,41 @@ namespace vcpkg::Commands::Integrate
|
||||||
{
|
{
|
||||||
const auto parsed = args.parse_arguments(COMMAND_STRUCTURE);
|
const auto parsed = args.parse_arguments(COMMAND_STRUCTURE);
|
||||||
|
|
||||||
if (parsed.command_arguments[0] == Subcommand::INSTALL)
|
if (Strings::case_insensitive_ascii_equals(parsed.command_arguments[0], INSTALL))
|
||||||
{
|
{
|
||||||
return integrate_install(paths);
|
return integrate_install(paths);
|
||||||
}
|
}
|
||||||
if (parsed.command_arguments[0] == Subcommand::REMOVE)
|
|
||||||
|
if (Strings ::case_insensitive_ascii_equals(parsed.command_arguments[0], REMOVE))
|
||||||
{
|
{
|
||||||
return integrate_remove(paths.get_filesystem());
|
return integrate_remove(paths.get_filesystem());
|
||||||
}
|
}
|
||||||
#if defined(_WIN32)
|
|
||||||
if (parsed.command_arguments[0] == Subcommand::PROJECT)
|
if (Strings ::case_insensitive_ascii_equals(parsed.command_arguments[0], PROJECT))
|
||||||
{
|
{
|
||||||
return integrate_project(paths);
|
return integrate_project(paths);
|
||||||
}
|
}
|
||||||
if (parsed.command_arguments[0] == Subcommand::POWERSHELL)
|
|
||||||
|
if (Strings ::case_insensitive_ascii_equals(parsed.command_arguments[0], POWERSHELL))
|
||||||
{
|
{
|
||||||
return integrate_powershell(paths);
|
return integrate_powershell(paths);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (parsed.command_arguments[0] == Subcommand::BASH)
|
if (Strings ::case_insensitive_ascii_equals(parsed.command_arguments[0], BASH))
|
||||||
{
|
{
|
||||||
return integrate_bash(paths);
|
return integrate_bash(paths);
|
||||||
}
|
}
|
||||||
if (parsed.command_arguments[0] == Subcommand::ZSH)
|
|
||||||
|
if (Strings ::case_insensitive_ascii_equals(parsed.command_arguments[0], ZSH))
|
||||||
{
|
{
|
||||||
return integrate_zsh(paths);
|
return integrate_zsh(paths);
|
||||||
}
|
}
|
||||||
if (parsed.command_arguments[0] == Subcommand::FISH)
|
|
||||||
|
if (Strings ::case_insensitive_ascii_equals(parsed.command_arguments[0], FISH))
|
||||||
{
|
{
|
||||||
return integrate_fish(paths);
|
return integrate_fish(paths);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
Checks::msg_exit_maybe_upgrade(
|
Checks::msg_exit_maybe_upgrade(
|
||||||
VCPKG_LINE_INFO, msgUnknownParameterForIntegrate, msg::value = parsed.command_arguments[0]);
|
VCPKG_LINE_INFO, msgUnknownParameterForIntegrate, msg::value = parsed.command_arguments[0]);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче