1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

Update rbenv module (#1007)

heres the changes

- Removed outdated code
- Replaced the old load-env with $env assignment
- Kept the rbenv command intact but focused on the "rbenv shell"
(modified a subcommand rather than the whole command)
- Deleted unused command completions
This commit is contained in:
Zh_Jk 2025-01-01 22:15:40 +08:00 committed by GitHub
parent de3865188e
commit d316685063
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 33 deletions

View file

@ -4,7 +4,7 @@ This script provides minimal working rbenv setup.
It can be used by importing its exported commands via: It can be used by importing its exported commands via:
``` ```
use path/to/rbenv.nu * use path/to/rbenv.nu
``` ```
With `path/to` being either the relative path of the file to your current working directory or its absolute path. With `path/to` being either the relative path of the file to your current working directory or its absolute path.

View file

@ -1,38 +1,19 @@
# rbenv # rbenv
export-env { export-env {
load-env { use std/util "path add"
PATH: ($env.PATH | split row (char esep) | prepend [$"($env.HOME)/.rbenv/bin" $"($env.HOME)/.rbenv/shims"])
RBENV_VERSION: "" $env.RBENV_SHELL = 'nu'
RBENV_VERSION_OLD: "" $env.RBENV_VERSION = ''
RBENV_SHELL: "nu" path add $"($env.HOME)/.rbenv/bin"
} path add $"($env.HOME)/.rbenv/shims"
} }
export def --env main [ export def --env "shell" [version: string] {
command?: string@'nu-complete rbenv', let run = (^rbenv sh-shell $version | complete)
...args if ($run.exit_code == 0) {
] { $env.RBENV_VERSION_OLD = ($env.RBENV_VERSION | default "")
let new_env = if $command in ["rehash", "shell"] { $env.RBENV_VERSION = $version
# implement each on indiviudaly e.g.
if $command == "shell" {
{ RBENV_VERSION_OLD: $env.RBENV_VERSION RBENV_VERSION: $args.0 }
} else {
error make { msg: $"`($command)` command is not supported yet" }
}
} else { } else {
if ($command | is-empty) { print -e $run.stderr
^rbenv
} else {
^rbenv $command $args
}
{}
} }
load-env $new_env
}
def 'nu-complete rbenv' [] {
^rbenv help
| lines
| where ($it | str starts-with " ")
| each {|entry| $entry | split row ' ' | get 0 }
} }