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

[Feature]: 支持使用环境变量指定要使用的插件名 #143

Open
bytemain opened this issue Mar 25, 2024 · 5 comments
Open

[Feature]: 支持使用环境变量指定要使用的插件名 #143

bytemain opened this issue Mar 25, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@bytemain
Copy link
Member

1. Your usage scenarios?

比如说我经常使用 nodejs,我敲命令时需要敲很长:

如果有环境变量,我就可以可以写一个 shell 函数,

function nvf() {
  VFOX_PLUGIN_NAME=nodejs vfox $*
}

这样我就只需要用 nvf use xxx 即可

2. What is your expected outcome?

可以通过环境变量设置插件名,设置插件名后使用插件不需要加 @ 了

@bytemain bytemain added the enhancement New feature or request label Mar 25, 2024
@bytemain bytemain self-assigned this Mar 25, 2024
@bytemain
Copy link
Member Author

@aooohan 看看我们需不需要实现这个功能,要的话我来做吧

@aooohan
Copy link
Member

aooohan commented Mar 25, 2024

如果我没理解错的话, 我们可以进一步优化:
假设新命令为short(后期再说).

vfox short nvf nodejs -> $VFOX_HOME下生成记录.

vfox activate -> 激活的时候, 顺便给他注入一个名字为nvf的函数. 里面就是你上面提到的写法.

打开shell之后, 就能直接使用nvf了.

nvf use xx
nvf i xx

等等

这样就可以避免设置环境变量了. 是这个意思不?

@bytemain
Copy link
Member Author

是的,现在每次都要指定插件名,要写的很长

@bytemain
Copy link
Member Author

听起来还是可以先从环境变量入手,因为要用一个标志来标志当前要使用的插件

@aooohan
Copy link
Member

aooohan commented Mar 25, 2024

听起来还是可以先从环境变量入手,因为要用一个标志来标志当前要使用的插件

不需要, vfox short nvf nodejs就已经指定了函数和插件的映射关系, 这个关系存本地就行啦.

vfox里面现成的结构来处理这个逻辑, https://github.com/version-fox/vfox/blob/main/internal/env/record.go

但是可能需要你将他抽成公共的, 目前仅.tool-versions使用.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants