Skip to content

Commit 59a905c

Browse files
committed
updated according to changes in the scripts location
1 parent f1d44e0 commit 59a905c

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

src-tauri/src/cli/mod.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ pub async fn run_cli(cli: Cli) -> anyhow::Result<()> {
401401
}
402402
config
403403
}
404-
Err(err) => {
404+
Err(_err) => {
405405
debug!("No ide config found. New will be created.");
406406
IdfConfig::default()
407407
}
@@ -412,21 +412,16 @@ pub async fn run_cli(cli: Cli) -> anyhow::Result<()> {
412412
if config.clone().is_path_in_config(dir.clone()) {
413413
info!("Already present!");
414414
} else {
415-
info!("Will be added...");
415+
info!("Can be added...");
416416
paths_to_add.push(dir);
417417
}
418-
419418
}
420-
// TODO: ask the user to select which IDFs to add
421-
for p in paths_to_add {
422-
match try_import_existing_idf(&p) {
423-
Ok(_) => {
424-
info!("Added to config: {}", p);
425-
}
426-
Err(err) => {
427-
error!("Failed to add: {} - reason :{}",p, err);
428-
}
429-
}
419+
if paths_to_add.is_empty() {
420+
info!("No new IDF directories found to add.");
421+
return Ok(());
422+
} else {
423+
info!("Found {} new IDF directories available to add:", paths_to_add.len());
424+
info!("You can add them using `eim install` command with the `--path` option.");
430425
}
431426
Ok(())
432427
}

src-tauri/src/lib/utils.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{
2-
command_executor::execute_command, idf_config::{IdfConfig, IdfInstallation}, idf_tools::{self, read_and_parse_tools_file}, replace_unescaped_spaces_win, settings::Settings, single_version_post_install, version_manager::get_default_config_path
2+
command_executor::execute_command, idf_config::{IdfConfig, IdfInstallation}, idf_tools::{self, read_and_parse_tools_file}, replace_unescaped_spaces_win, settings::{self, Settings}, single_version_post_install, version_manager::get_default_config_path
33
};
44
use anyhow::{anyhow, Result, Error};
55
use git2::Repository;
@@ -389,8 +389,6 @@ pub fn parse_tool_set_config(config_path: &str) -> Result<()> {
389389
.unwrap()
390390
.to_string();
391391
let new_export_paths = vec![tool_set.env_vars.get("PATH").unwrap().to_string()];
392-
let tmp = PathBuf::from(tool_set.idf_location.clone());
393-
let version_path = tmp.parent().unwrap();
394392
let settings = crate::settings::Settings::default();
395393
let activation_script_path = settings.esp_idf_json_path.clone().unwrap_or_default();
396394
single_version_post_install(
@@ -405,11 +403,11 @@ pub fn parse_tool_set_config(config_path: &str) -> Result<()> {
405403
let new_activation_script = match std::env::consts::OS {
406404
"windows" => format!(
407405
"{}\\Microsoft.PowerShell_profile.ps1",
408-
version_path.to_str().unwrap()
406+
activation_script_path
409407
),
410408
_ => format!(
411409
"{}/activate_idf_{}.sh",
412-
version_path.to_str().unwrap(),
410+
activation_script_path,
413411
tool_set.idf_version
414412
),
415413
};
@@ -437,7 +435,7 @@ pub fn parse_tool_set_config(config_path: &str) -> Result<()> {
437435
None => {
438436
debug!("Adding new IDF installation to config");
439437
current_config.idf_installed.push(installation);
440-
match current_config.to_file(config_path, true, false) {
438+
match current_config.to_file(config_path, true, true) {
441439
Ok(_) => {
442440
debug!("Updated config file with new tool set");
443441
return Ok(());
@@ -492,11 +490,12 @@ pub fn parse_esp_idf_json(idf_json_path: &str) -> Result<()> {
492490
let idf_path = value.path;
493491
let python = value.python;
494492
let tools_path = config.idf_tools_path.clone();
495-
let path_for_activation_script = idf_json_path.parent().unwrap().to_str().unwrap();
493+
let settings = crate::settings::Settings::default();
494+
let path_for_activation_script = settings.esp_idf_json_path.clone().unwrap_or_default();
496495

497496
println!("IDF tools path: {}", tools_path);
498497
println!("IDF version: {}", idf_version);
499-
println!("activation script path: {}", path_for_activation_script);
498+
println!("activation script path: {}", &path_for_activation_script);
500499
println!("Python path: {}", python);
501500
// export paths
502501
let tools_json_file = find_by_name_and_extension(Path::new(&idf_path), "tools", "json");
@@ -528,7 +527,7 @@ pub fn parse_esp_idf_json(idf_json_path: &str) -> Result<()> {
528527
.collect();
529528
export_paths.push(config.git_path.clone());
530529
match import_single_version(
531-
path_for_activation_script,
530+
&path_for_activation_script,
532531
&idf_path,
533532
&idf_version,
534533
&tools_path,
@@ -674,7 +673,7 @@ pub fn import_single_version(path_to_create_activation_script: &str,idf_location
674673
),
675674
_ => format!(
676675
"{}/activate_idf_{}.sh",
677-
PathBuf::from(path_to_create_activation_script).parent().unwrap().to_str().unwrap(),
676+
path_to_create_activation_script,
678677
idf_version
679678
),
680679
};

0 commit comments

Comments
 (0)