winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit edfc884fd3a54ff1cda372bbe7588d8025d0e1e1
parent 5cd56162ecd70d84f19c01f11320afb9a1995ea2
Author: Kaleb Luedtke <jluedtk@jci.com>
Date:   Tue, 25 Oct 2022 13:40:41 -0500

Print command aliases added on portable install (#2621)


Diffstat:
Msrc/AppInstallerCLICore/PortableInstaller.cpp | 57++++++++++++++++++++++++++++++---------------------------
Msrc/AppInstallerCLICore/Resources.h | 1+
Msrc/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw | 4++++
3 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/src/AppInstallerCLICore/PortableInstaller.cpp b/src/AppInstallerCLICore/PortableInstaller.cpp @@ -110,37 +110,41 @@ namespace AppInstaller::CLI::Portable AICLI_LOG(Core, Info, << "Moving directory to: " << filePath); Filesystem::RenameFile(entry.CurrentPath, filePath); } - else if (entry.FileType == PortableFileType::Symlink && !InstallDirectoryAddedToPath) + else if (entry.FileType == PortableFileType::Symlink) { - std::filesystem::file_status status = std::filesystem::status(filePath); - if (std::filesystem::is_directory(status)) + if (!InstallDirectoryAddedToPath) { - AICLI_LOG(CLI, Info, << "Unable to create symlink. '" << filePath << "points to an existing directory."); - THROW_HR(APPINSTALLER_CLI_ERROR_PORTABLE_SYMLINK_PATH_IS_DIRECTORY); - } + std::filesystem::file_status status = std::filesystem::status(filePath); + if (std::filesystem::is_directory(status)) + { + AICLI_LOG(CLI, Info, << "Unable to create symlink. '" << filePath << "points to an existing directory."); + THROW_HR(APPINSTALLER_CLI_ERROR_PORTABLE_SYMLINK_PATH_IS_DIRECTORY); + } - if (!RecordToIndex) - { - CommitToARPEntry(PortableValueName::PortableSymlinkFullPath, filePath); - } + if (!RecordToIndex) + { + CommitToARPEntry(PortableValueName::PortableSymlinkFullPath, filePath); + } - if (std::filesystem::remove(filePath)) - { - AICLI_LOG(CLI, Info, << "Removed existing file at " << filePath); - m_stream << Resource::String::OverwritingExistingFileAtMessage << ' ' << filePath.u8string() << std::endl; - } + if (std::filesystem::remove(filePath)) + { + AICLI_LOG(CLI, Info, << "Removed existing file at " << filePath); + m_stream << Resource::String::OverwritingExistingFileAtMessage << ' ' << filePath.u8string() << std::endl; + } - if (Filesystem::CreateSymlink(entry.SymlinkTarget, filePath)) - { - AICLI_LOG(Core, Info, << "Symlink created at: " << filePath); - } - else - { - // Symlink creation should only fail if the user executes without admin rights or developer mode. - // Resort to adding install directory to PATH directly. - AICLI_LOG(Core, Info, << "Portable install executed in user mode. Adding package directory to PATH."); - CommitToARPEntry(PortableValueName::InstallDirectoryAddedToPath, InstallDirectoryAddedToPath = true); + if (Filesystem::CreateSymlink(entry.SymlinkTarget, filePath)) + { + AICLI_LOG(Core, Info, << "Symlink created at: " << filePath); + } + else + { + // Symlink creation should only fail if the user executes without admin rights or developer mode. + // Resort to adding install directory to PATH directly. + AICLI_LOG(Core, Info, << "Portable install executed in user mode. Adding package directory to PATH."); + CommitToARPEntry(PortableValueName::InstallDirectoryAddedToPath, InstallDirectoryAddedToPath = true); + } } + m_stream << Resource::String::PortableAliasAdded << ' ' << filePath.stem() << std::endl; } } @@ -464,4 +468,4 @@ namespace AppInstaller::CLI::Portable return false; } } -}- \ No newline at end of file +} diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h @@ -237,6 +237,7 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(PoliciesState); WINGET_DEFINE_RESOURCE_STRINGID(PortableHashMismatchOverridden); WINGET_DEFINE_RESOURCE_STRINGID(PortableHashMismatchOverrideRequired); + WINGET_DEFINE_RESOURCE_STRINGID(PortableAliasAdded); WINGET_DEFINE_RESOURCE_STRINGID(PortableInstallFailed); WINGET_DEFINE_RESOURCE_STRINGID(PortablePackageAlreadyExists); WINGET_DEFINE_RESOURCE_STRINGID(PortableRegistryCollisionOverridden); diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -1341,6 +1341,10 @@ Please specify one of them using the `--source` option to proceed.</value> <data name="NoPackageSelectionArgumentProvided" xml:space="preserve"> <value>No package selection argument was provided; see the help for details about finding a package.</value> </data> + <data name="PortableAliasAdded" xml:space="preserve"> + <value>Command line alias added:</value> + + </data> <data name="PortableInstallFailed" xml:space="preserve"> <value>Portable install failed; Cleaning up...</value> </data>