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

feat(scoop-alter): Add scoop alter command to switch shim's target #4727

Merged
merged 5 commits into from
Feb 13, 2022

Conversation

niheaven
Copy link
Member

@niheaven niheaven commented Feb 9, 2022

A WONDERFUL FEATURE OF SCOOP 😆 🎉

Description

Now Scoop could switch apps using scoop alter <app> just as (update-)alternatives in Linux. Meanwhile, uninstalling some apps which overwrite other's shims will restore previous ones (instead of removing commands).

  • Instead of overwriting shims, Scoop renames original ones.
  • During the uninstalling process, if there're renamed shims, Scoop will rename them back.
  • Add new scoop alter command to choose default of command (a.k.a., shim)

Motivation and Context

There are many issues requesting this feature (just incomplete lists):

How Has This Been Tested?

Tested in PowerShell 5.1/7.2.1, CMD, and WSL/Ubuntu. (Not tested in MSYS2 and CygWin)

Use 7zip/7zip-zstd and python/python3 as examples:

image

image

Uninstallation:

image

For command without alternatives:

image

For command without shim:

image

Checklist:

  • I have read the Contributing Guide.
  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.

@niheaven niheaven changed the title feat(shim): Allow switching shim's target feat(scoop-alter): Add scoop alter command to switch shim's target Feb 9, 2022
@rashil2000
Copy link
Member

Wow, very interesting!

Some notes:

  • Since we are changing/refactoring function signatures, would it be good to follow PS conventions and call it Remove-Shim instead of rm_shim?
  • In a subsequent PR, I might add a functionality to create user-defined shims, to solve Adding shims to an installation #3303. Since this is related to shims itself, should we call the file something other than scoop-alter.ps1?

@niheaven
Copy link
Member Author

I'll make another PR that moves all shim-related functions to a separate file and refactors all the functions using PowerShell conventions, it's better IMO, right?

The 'user-defined shims' in #3303 is more likely links, it links a virtual app folder to some existing one and make new shims that points to them (likes scoop reset), have I misunderstood?

@rashil2000
Copy link
Member

I'll make another PR that moves all shim-related functions to a separate file and refactors all the functions using PowerShell conventions, it's better IMO, right?

Sure.

The 'user-defined shims' in #3303 is more likely links, it links a virtual app folder to some existing one and make new shims that points to them (likes scoop reset), have I misunderstood?

No no, the idea is to allow creation of custom shims. For example, I want to create a shim like this:

scoop shim nvimdiff D:\Data\Scoop\apps\neovim\bin\nvim.exe -d

The nvimdiff shim is not created by the neovim manifest, but we can allow users to create custom shims like this. The format would be:

scoop shim <shim_name> <full_path_to_program> <arg1> <arg2> <arg3> ...

@niheaven
Copy link
Member Author

Okay, got it.

scoop alter is more user-friendly IMO, end users needn't know what is 'shim' and they just alter the command. A specific command scoop shim for advanced users could add a subcommand that directly call it. scoop shim might have following subcommand:

  • scoop shim <command> shows where the command comes from
    • likes scoop which, could call it directly or modify some output likes ' is from '
  • scoop shim alter <command> calls scoop alter to change command's source
  • scoop shim add <shim_name> <full_path_to_program> <arg1> <arg2> <arg3> ...
    • this is what you want
  • scoop shim rm/del <command> remove shim
    • maybe give some caution notes?

@niheaven
Copy link
Member Author

Any other suggestions? @rashil2000 @issaclin32

@rashil2000
Copy link
Member

Yes, plan looks awesome!

But why create both scoop-alter and scoop-shim if scoop shim alter exist?

@niheaven
Copy link
Member Author

Yes, plan looks awesome!

But why create both scoop-alter and scoop-shim if scoop shim alter exist?

For convenience 😆 . For example, in my use cases, I may never use scoop shim except for scoop shim alter if there is only scoop shim, and this is the general usage for most users IMO.

@rashil2000
Copy link
Member

To be honest, the command scoop shim alter is more clear as to what exactly it is doing. scoop alter could mean anything (and not just shims). @issaclin32 thoughts?

@issaclin32
Copy link
Member

I would vote for scoop shim alter. It looks more intuitive.

@niheaven
Copy link
Member Author

This is not a binary choice; they are mutually inclusive. If only scoop shim alter is kept, I'll do some additional coding that adds basic functions of scoop shim.

@niheaven
Copy link
Member Author

@rashil2000 I've done scoop shim command, but I prefer merge this PR and I'll submit a new one that accomplish the feature.

libexec/scoop-alter.ps1 Outdated Show resolved Hide resolved
libexec/scoop-alter.ps1 Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants