Bios-Marcel / spoon

Fast `scoop search`, (WIP) full scoop replacement and tab completion
BSD 3-Clause "New" or "Revised" License
5 stars 1 forks source link

Spoon shell (WIP) #5

Closed Bios-Marcel closed 5 months ago

Bios-Marcel commented 6 months ago

spoon shell is a command native to spoon. It uses scoop and some additional logic in order to provide something akin to nix-shell.

For now this will mostly use scoop as a backend, since the necessary elements haven't been implemented in spoon yet.

Supported shells for now are pwsh and powershell. It seems however, that subshelling isn't easily possible from within a go executable. So instead we generate a powershell file that requires manual execution.

An alternative approach would be, to actually provide a wrapper powershell script for spoon, so that we are already in a powershell context, allowing us to communicate to the wrapper that we'd like a subshell.

Testing

TODO, make tests using windows native containers. (See wastebasket v2, i did it there too)

Test PR

Install via:

go install github.com/Bios-Marcel/spoon/cmd/spoon@spoon_shell

Planned UX

spoon shell setup apps...

Will create a .scoop folder containing the desired applications. Additionally, we'll get a shell.ps1 script that will open the subshell containing path entries for the locally installed applications.

Rerunning the same command with different apps will cleanup. This means that previously installed apps will be gone and new ones will be added.

spoon shell clean

Will delete both .scoop and shell.ps1.

To make usage in a project easier, you can create a script such as setup_scoop.ps1:

$packages = @(
    # Used for ...
    'lua',
    # Important to use this version because ...
    'golangci-lint@1.56.1',
    # Pinned node major version from versions bucket
    'versions/nodejs18'
)

spoon shell setup $packages

This way you can easily version your dependencies and document them.

Notes

While there are similar tools to this, such as devenv, it's not very Windows-native. But spoon shell works outside of WSL (support inside WSL soonTM).

This would also obsolete tools such as nvm.