Skip to content

Commit

Permalink
Esp idf json (#54)
Browse files Browse the repository at this point in the history
* added esp_idf_json_path cli argument

* creating the esp_ide.json file added

* library version rised

---------

Co-authored-by: Petr Gadorek <[email protected]>
  • Loading branch information
Hahihula and Petr Gadorek authored Nov 5, 2024
1 parent e2fe1f5 commit 23ee537
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
tokio = {version = "1.37.0", features=["full"]}
idf-im-lib = { git = "https://github.com/espressif/idf-im-lib.git", tag="v0.1.3" }
idf-im-lib = { git = "https://github.com/espressif/idf-im-lib.git", tag="v0.1.4" }
clap = {version = "4.5", features = ["cargo", "derive", "color"]}
crossterm = "0.27.0"
dialoguer = { git = "https://github.com/Hahihula/dialoguer.git", branch = "folder-select", features = ["folder-select"] }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

EIM is a cross-platform CLI application that simplifies the setup process for ESP-IDF (Espressif IoT Development Framework). Whether you’re working on macOS, Linux, or Windows, EIM offers a consistent and user-friendly experience for installing prerequisites, ESP-IDF itself, and essential development tools.

[![Documentation](https://img.shields.io/badge/documentation-white?style=for-the-badge&logo=readthedocs&logoColor=red)](https://preview-docs.espressif.com/projects/idf-im-cli/en/latest/index.html)
[![Documentation](https://img.shields.io/badge/documentation-white?style=for-the-badge&logo=readthedocs&logoColor=red)](https://docs.espressif.com/projects/idf-im-cli/en/latest/index.html)

## Configuration

Expand Down
11 changes: 11 additions & 0 deletions src/cli_args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ pub struct Cli {
help = "Base Path to which all the files and folder will be installed"
)]
path: Option<String>,

#[arg(
long,
help = "Absolute path to save esp_idf.json file. Default is $HOME/.esp_installation_manager/esp_idf.json"
)]
esp_idf_json_path: Option<String>,

#[arg(short, long, value_name = "FILE")]
pub config: Option<PathBuf>,

Expand Down Expand Up @@ -117,6 +124,10 @@ impl IntoIterator for Cli {
fn into_iter(self) -> Self::IntoIter {
vec![
("path".to_string(), self.path.map(Into::into)),
(
"esp_idf_json_path".to_string(),
self.esp_idf_json_path.map(Into::into),
),
(
"config".to_string(),
self.config.map(|p| p.to_str().unwrap().into()),
Expand Down
23 changes: 22 additions & 1 deletion src/wizard/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dialoguer::FolderSelect;
use idf_im_lib::idf_tools::ToolsFile;
use idf_im_lib::settings::Settings;
use idf_im_lib::{DownloadProgress, ProgressMessage};
use idf_im_lib::{ensure_path, DownloadProgress, ProgressMessage};
use indicatif::{ProgressBar, ProgressState, ProgressStyle};
use log::{debug, error, info, warn};
use rust_i18n::t;
Expand Down Expand Up @@ -559,6 +559,27 @@ pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> {
)
}
save_config_if_desired(&config)?;
let ide_conf_path_tmp = PathBuf::from(
&config.esp_idf_json_path.clone().unwrap_or(
dirs::home_dir()
.unwrap()
.join(".esp_installation_manager")
.to_str()
.unwrap()
.to_string(),
),
);
match ensure_path(ide_conf_path_tmp.to_str().unwrap()) {
Ok(_) => (),
Err(err) => {
error!("Failed to create IDE configuration directory: {}", err);
return Err(err.to_string());
}
}
let ide_conf_path = ide_conf_path_tmp.join("esp_ide.json");
println!("^^^^^^^^^ {}", &ide_conf_path.to_str().unwrap());
config.save_esp_ide_json(ide_conf_path.to_str().unwrap())?;

match std::env::consts::OS {
"windows" => {
println!("{}", t!("wizard.windows.finish_steps.line_1"));
Expand Down

0 comments on commit 23ee537

Please sign in to comment.