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

XVM Base - minimal implement #60

Merged
merged 7 commits into from
Jan 4, 2025
Merged

XVM Base - minimal implement #60

merged 7 commits into from
Jan 4, 2025

Conversation

Sunrisepeak
Copy link
Member

@Sunrisepeak Sunrisepeak commented Dec 28, 2024

Copy link
Collaborator

@lvyuemeng lvyuemeng Jan 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let mut workspace = if ...

Comment on lines 273 to 279
let mut program = shims::Program::new(target, version);
let vdb = xvmlib::get_versiondb();
let vdata = vdb
.get_vdata(target, version)
.expect("Version data not found");

program.set_vdata(vdata);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to unify vdata to shims initialization.
Such set_vdata is vulnerable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

input(env, path, ...) - > program < - > vdata. vdata is a data-format, but isnot necessary

let vdb = xvmlib::get_versiondb();

if vdb.get_vdata(target, version).is_none() {
panic!("Version not found");
Copy link
Collaborator

@lvyuemeng lvyuemeng Jan 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

panic will suddenly interrupt all program, it won't return an IO error.

name: String,
version: String,
filename: Option<String>,
path: String,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should use PathBuf for file path.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo

@Sunrisepeak
Copy link
Member Author

Sunrisepeak commented Jan 4, 2025

minial implement for xvm:

  • version manager by shim/env
  • support command alias
  • support workspace [global + dir]

TODO:

  • String -> PathBuff
  • Optimize Error Handle
  • better workspace implement (use workspace id/name to identify, rather then dir)
  • shim-program: add direct mode

@Sunrisepeak Sunrisepeak merged commit 32b73ac into main Jan 4, 2025
1 check passed
@Sunrisepeak Sunrisepeak changed the title XVM Base - Todo XVM Base - minimal implement Jan 4, 2025
@Sunrisepeak
Copy link
Member Author

xvm cannot modify env for current shell/cmd,
how to use id/name to identify workspace (dont need user to Refresh )?

@MoYingJi
Copy link
Collaborator

MoYingJi commented Jan 5, 2025

xvm cannot modify env for current shell/cmd

将xvm写成sh文件 文件里调用真正的xvm二进制 二进制文件处理时将需要执行的命令写入另一个文件 然后在sh文件的末尾检测并执行文件?
我搜了一下有 std::env 不行吗?

how to use id/name to identify workspace (dont need user to Refresh )?

修改 prompt (也就是shell命令前的用来显示用户名、路径、信息的)
各 shell 应该都会提供这一接口
但我们想要的效果是cd后执行命令 也就是不绘制任何东西 仅判断$PWD如果变动就调用xvm执行一些东西

或者 直接 alias cd?

@lvyuemeng
Copy link
Collaborator

lvyuemeng commented Jan 6, 2025

xvm cannot modify env for current shell/cmd, how to use id/name to identify workspace (dont need user to Refresh )?

No way for automatic detection. Because CLI is passive, and you can only do something by user calling. So workspace should be project oriented and not suitable for a general env control, you need to develop a activation that initialize a new shell with env, that's the way of your workspace done. Second, the proper way to use a shim is to replace the user path with your shim path. The shim should be executable to automatically detect and switch version, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature | 功能 New feature or request xvm模块
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants