-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: Allow install, list and use from commit #2659
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
use anyhow::{Error, Result}; | ||
use avm::InstallTarget; | ||
use clap::{Parser, Subcommand}; | ||
use semver::Version; | ||
|
||
|
@@ -20,8 +21,10 @@ pub enum Commands { | |
}, | ||
#[clap(about = "Install a version of Anchor")] | ||
Install { | ||
#[clap(value_parser = parse_version)] | ||
version: Version, | ||
/// Anchor version or commit | ||
version: String, | ||
#[clap(short, long, required = false)] | ||
is_commit: bool, | ||
#[clap(long)] | ||
/// Flag to force installation even if the version | ||
/// is already installed | ||
|
@@ -46,10 +49,23 @@ fn parse_version(version: &str) -> Result<Version, Error> { | |
Version::parse(version).map_err(|e| anyhow::anyhow!(e)) | ||
} | ||
} | ||
|
||
fn parse_install_target(version_or_commit: String, is_commit: bool) -> InstallTarget { | ||
if is_commit { | ||
InstallTarget::Commit(version_or_commit) | ||
} else { | ||
InstallTarget::Version(parse_version(&version_or_commit).unwrap()) | ||
} | ||
} | ||
|
||
pub fn entry(opts: Cli) -> Result<()> { | ||
match opts.command { | ||
Commands::Use { version } => avm::use_version(version), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've tried it and confirm it works as expected but one area that might need improvement is |
||
Commands::Install { version, force } => avm::install_version(&version, force), | ||
Commands::Install { | ||
version, | ||
is_commit, | ||
force, | ||
} => avm::install_anchor(parse_install_target(version, is_commit), force), | ||
Commands::Uninstall { version } => avm::uninstall_version(&version), | ||
Commands::List {} => avm::list_versions(), | ||
Commands::Update {} => avm::update(), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing this is not implemented yet. Don't think
is_commit
flag is necessary, can just decide whether it's a version or a commit based on the input.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to push, pushed and back to single arg
Trying to install an incorrect commit
We can also provide a shortened commit sha with
518b390