Skip to content

Commit b06d894

Browse files
committed
updated according to changes in the scripts location
1 parent 58d77e5 commit b06d894

File tree

3 files changed

+20
-58
lines changed

3 files changed

+20
-58
lines changed

src-tauri/src/cli/mod.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ pub async fn run_cli(cli: Cli) -> anyhow::Result<()> {
322322
}
323323
Commands::Discover {path } => {
324324
info!("Discovering available versions... (This can take couple of minutes)");
325-
// TODO: add warning and confirmation
326325
let path = path.unwrap_or_else(|| {
327326
let default_path = match std::env::consts::OS {
328327
"windows" => {
@@ -401,7 +400,7 @@ pub async fn run_cli(cli: Cli) -> anyhow::Result<()> {
401400
}
402401
config
403402
}
404-
Err(err) => {
403+
Err(_err) => {
405404
debug!("No ide config found. New will be created.");
406405
IdfConfig::default()
407406
}
@@ -412,21 +411,16 @@ pub async fn run_cli(cli: Cli) -> anyhow::Result<()> {
412411
if config.clone().is_path_in_config(dir.clone()) {
413412
info!("Already present!");
414413
} else {
415-
info!("Will be added...");
414+
info!("Can be added...");
416415
paths_to_add.push(dir);
417416
}
418-
419417
}
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-
}
418+
if paths_to_add.is_empty() {
419+
info!("No new IDF directories found to add.");
420+
return Ok(());
421+
} else {
422+
info!("Found {} new IDF directories available to add:", paths_to_add.len());
423+
info!("You can add them using `eim install` command with the `--path` option.");
430424
}
431425
Ok(())
432426
}

src-tauri/src/gui/mod.rs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -170,37 +170,6 @@ impl ToolSetup {
170170
}
171171
}
172172

173-
// async fn install_single_version(
174-
// app_handle: AppHandle,
175-
// settings: &Settings,
176-
// version: String,
177-
// ) -> Result<(), Box<dyn std::error::Error>> {
178-
// info!("Installing IDF version: {}", version);
179-
180-
// let version_path = prepare_installation_directories(app_handle.clone(), settings, &version)?;
181-
// let idf_path = version_path.clone().join("esp-idf");
182-
// download_idf(&app_handle, settings, &version, &idf_path).await?;
183-
// let export_vars = setup_tools(&app_handle, settings, &idf_path, &version).await?;
184-
// let tools_install_path = version_path.clone().join(
185-
// settings
186-
// .tool_install_folder_name
187-
// .clone()
188-
// .unwrap_or_default(),
189-
// );
190-
// let idf_python_env_path = tools_install_path.clone().join("python").join(&version).join("venv");
191-
// let activation_script_path = settings.esp_idf_json_path.clone().unwrap_or_default();
192-
// idf_im_lib::single_version_post_install(
193-
// &activation_script_path,
194-
// idf_path.to_str().unwrap(),
195-
// &version,
196-
// tools_install_path.to_str().unwrap(),
197-
// export_vars,
198-
// Some(idf_python_env_path.to_str().unwrap()),
199-
// );
200-
201-
// Ok(())
202-
// }
203-
204173
// Helper function to check if a process is running on Windows
205174
#[cfg(target_os = "windows")]
206175
fn is_process_running(pid: u32) -> bool {

src-tauri/src/lib/utils.rs

Lines changed: 12 additions & 13 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,12 +490,13 @@ 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

497-
println!("IDF tools path: {}", tools_path);
498-
println!("IDF version: {}", idf_version);
499-
println!("activation script path: {}", path_for_activation_script);
500-
println!("Python path: {}", python);
496+
debug!("IDF tools path: {}", tools_path);
497+
debug!("IDF version: {}", idf_version);
498+
debug!("activation script path: {}", &path_for_activation_script);
499+
debug!("Python path: {}", python);
501500
// export paths
502501
let tools_json_file = find_by_name_and_extension(Path::new(&idf_path), "tools", "json");
503502
if tools_json_file.is_empty() {
@@ -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)