From 4267ad9d747a383999f1c8499cc68a5ce8ed96fc Mon Sep 17 00:00:00 2001 From: Hahihula Date: Wed, 10 Jul 2024 15:05:32 +0200 Subject: [PATCH] added possibility to download idf from master (#8) Co-authored-by: Petr Gadorek --- Cargo.lock | 2 +- README.md | 2 ++ src/cli_args/mod.rs | 4 ++-- src/wizard/mod.rs | 24 ++++++++++++++++++------ 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 54966b6..fb261ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1779,7 +1779,7 @@ dependencies = [ [[package]] name = "idf-im-lib" version = "0.1.0" -source = "git+https://github.com/espressif/idf-im-lib.git?branch=master#468d678c9c9e5f4798d8951da776182a68bdaeef" +source = "git+https://github.com/espressif/idf-im-lib.git?branch=master#aa8ee079cb2521ead000b2483ea03c67160bd10f" dependencies = [ "colored", "decompress", diff --git a/README.md b/README.md index 4b3abdd..d82631d 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ please refer to the --help for information about cli usage Download the executable for the suitable architecture. +it is recomanded to first run the `--help` command + Run it and proceed according to instruction in the terminal and you will have IDF installed. for chinese run it with flag `-l=cn` diff --git a/src/cli_args/mod.rs b/src/cli_args/mod.rs index 5e17132..80a33ec 100644 --- a/src/cli_args/mod.rs +++ b/src/cli_args/mod.rs @@ -67,7 +67,7 @@ pub struct Cli { #[arg( long, - help = "url for dowenload mirror to use instead of github.com for downloading esp-idf" + help = "url for download mirror to use instead of github.com for downloading esp-idf" )] idf_mirror: Option, @@ -79,7 +79,7 @@ pub struct Cli { )] verbose: u8, - #[arg(short, long, help = "Set the language for the wizard")] + #[arg(short, long, help = "Set the language for the wizard (en, cn)")] locale: Option, } diff --git a/src/wizard/mod.rs b/src/wizard/mod.rs index 2be0226..f388de6 100644 --- a/src/wizard/mod.rs +++ b/src/wizard/mod.rs @@ -86,9 +86,9 @@ async fn select_target(theme: &ColorfulTheme) -> Result { } async fn select_idf_version(target: &str, theme: &ColorfulTheme) -> Result { - let avalible_versions = + let mut avalible_versions = idf_im_lib::idf_versions::get_idf_name_by_target(&target.to_string().to_lowercase()).await; - + avalible_versions.push("master".to_string()); let selected_version = Select::with_theme(theme) .with_prompt(t!("wizard.select_idf_version.prompt")) .items(&avalible_versions) @@ -99,7 +99,7 @@ async fn select_idf_version(target: &str, theme: &ColorfulTheme) -> Result) -> Result { +fn download_idf(path: &str, tag: Option<&str>, mirror: Option<&str>) -> Result { let _: Result = match idf_im_lib::ensure_path(&path.to_string()) { Ok(_) => Ok("ok".to_string()), Err(err) => return Err(err.to_string()), // probably panic @@ -118,7 +118,7 @@ fn download_idf(path: &str, tag: &str, mirror: Option<&str>) -> Result Result<(), String> { debug!("Selected target: {}", target); // select version if config.idf_version.is_none() { - config.idf_version = Some(select_idf_version(&target, &theme).await.unwrap()); + let selected_idf_version = select_idf_version(&target, &theme).await; + match selected_idf_version { + Ok(selected_idf_version) => config.idf_version = Some(selected_idf_version), + Err(err) => { + error!("{:?}", err); + return Err(err); + } + } } let idf_versions = config.idf_version.unwrap(); debug!("Selected idf version: {}", idf_versions); @@ -456,9 +463,14 @@ pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> { } }; // download idf + let tag = if idf_versions == "master" { + None + } else { + Some(idf_versions.clone()) + }; match download_idf( &idf_path.to_str().unwrap(), - &idf_versions, + tag.as_deref(), Some(&idf_mirror), ) { Ok(_) => {