Skip to content

Commit

Permalink
rename binary and minor polish
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Gadorek committed Aug 6, 2024
1 parent 8b2d973 commit 32d14de
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/build_rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,28 @@ jobs:

- name: Create release directory
run: mkdir -p release

- name: Create release system directory
run: mkdir -p release/${{ matrix.os }}

- name: Copy binary to release directory Windows
if: matrix.os == 'windows-latest'
run: cp target/release/idf-im-cli.exe release/idf-im-cli-${{ matrix.os }}.exe
run: cp target/release/idf-im-cli.exe release/${{ matrix.os }}/eim.exe

- name: Copy binary to release directory POSIX
if: matrix.os != 'windows-latest'
run: cp target/release/idf-im-cli release/idf-im-cli-${{ matrix.os }}
run: cp target/release/idf-im-cli release/${{ matrix.os }}/eim

- name: Upload build artifacts for POSIX
uses: actions/upload-artifact@v4
if: matrix.os != 'windows-latest'
with:
name: idf-im-cli-${{ matrix.os }}
path: release/idf-im-cli-${{ matrix.os }}
name: ${{ matrix.os }}_eim
path: release/${{ matrix.os }}/eim

- name: Upload build artifacts for Windows
uses: actions/upload-artifact@v4
if: matrix.os == 'windows-latest'
with:
name: idf-im-cli-${{ matrix.os }}.exe
path: release/idf-im-cli-${{ matrix.os }}.exe
name: eim.exe
path: release/${{ matrix.os }}/eim.exe
8 changes: 4 additions & 4 deletions src/cli_args/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use clap::builder::styling::{AnsiColor, Color, Style, Styles};
use clap::{arg, command, value_parser, ColorChoice, Parser, ValueEnum};
use clap::{arg, command, ColorChoice, Parser, ValueEnum};
use config::{Config, ConfigError, File};
use idf_im_lib::get_log_directory;
use log::{debug, error, info};
use log::{debug, info};
use serde::{Deserialize, Serialize};
use std::fs::OpenOptions;
use std::io::Write;
Expand Down Expand Up @@ -136,12 +136,12 @@ impl IntoIterator for Cli {
(
"target".to_string(),
self.target
.map(|s| s.split(",").collect::<Vec<&str>>().into()),
.map(|s| s.split(',').collect::<Vec<&str>>().into()),
),
(
"idf_version".to_string(),
self.idf_versions
.map(|s| s.split(",").collect::<Vec<&str>>().into()),
.map(|s| s.split(',').collect::<Vec<&str>>().into()),
),
(
"tool_download_folder_name".to_string(),
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ extern crate idf_im_lib;

mod cli_args;
mod wizard;
use rust_i18n::t;

rust_i18n::i18n!("locales", fallback = "en");

Expand Down
31 changes: 14 additions & 17 deletions src/wizard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ async fn select_idf_version(target: &str, theme: &ColorfulTheme) -> Result<Vec<S
return Err("You must select IDF version".to_string());
}

return Ok(selected_version
Ok(selected_version
.into_iter()
.map(|i| avalible_versions[i].clone())
.collect());
.collect())
}

fn download_idf(
Expand All @@ -128,7 +128,7 @@ fn download_idf(
mirror: Option<&str>,
group_name: Option<&str>,
) -> Result<String, String> {
let _: Result<String, String> = match idf_im_lib::ensure_path(&path.to_string()) {
let _: Result<String, String> = match idf_im_lib::ensure_path(path) {
Ok(_) => Ok("ok".to_string()),
Err(err) => return Err(err.to_string()), // probably panic
};
Expand All @@ -145,7 +145,7 @@ fn download_idf(
);

let output = idf_im_lib::get_esp_idf_by_tag_name(
&path.to_string(),
path,
tag,
|stats| {
let current_progress =
Expand Down Expand Up @@ -340,8 +340,6 @@ fn add_to_shell_rc(content: &str) -> Result<(), String> {
Ok(())
}

fn install_python_environment() {}

pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> {
debug!("Config entering wizard: {:?}", config);

Expand All @@ -358,7 +356,7 @@ pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> {
};

// check prerequisites
match run_with_spinner::<_, Result<Vec<String>, String>>(|| check_prerequisites()) {
match run_with_spinner::<_, Result<Vec<String>, String>>(check_prerequisites) {
Ok(list) => {
if list.is_empty() {
info!("{}", t!("prerequisites.ok"));
Expand Down Expand Up @@ -410,7 +408,7 @@ pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> {
}
}
info!("{}", t!("python.sanitycheck.info"));
match run_with_spinner::<_, Result<(), String>>(|| python_sanity_check()) {
match run_with_spinner::<_, Result<(), String>>(python_sanity_check) {
Ok(_) => {
info!("{}", t!("python.sanitycheck.ok"))
}
Expand Down Expand Up @@ -558,7 +556,7 @@ pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> {
Some(idf_version.clone())
};
match download_idf(
&idf_path.to_str().unwrap(),
idf_path.to_str().unwrap(),
tag.as_deref(),
Some(&idf_mirror),
group_name,
Expand Down Expand Up @@ -659,7 +657,7 @@ pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> {
config.tools_json_file = Some(default_tools_json_file_location.to_string());
}

if !fs::metadata(&tools_json_file).is_ok() {
if fs::metadata(&tools_json_file).is_err() {
warn!("{}", t!("wizard.tools_json.not_found"));
let tools_json_file_select = FolderSelect::with_theme(&theme)
.with_prompt(t!("wizard.tools_json.select.prompt"))
Expand Down Expand Up @@ -747,7 +745,7 @@ pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> {
idf_tools_path.push(default_idf_tools_py_file_location);
config.idf_tools_path = Some(default_idf_tools_py_file_location.to_string());
}
if !fs::metadata(&idf_tools_path).is_ok() {
if fs::metadata(&idf_tools_path).is_err() {
warn!("{}", t!("wizard.idf_tools.not_found"));
let idf_tools_py_select = FolderSelect::with_theme(&theme)
.with_prompt(t!("wizard.idf_tools.select.prompt"))
Expand Down Expand Up @@ -832,9 +830,9 @@ pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> {
.map(|(k, v)| format!("export {}=\"{}\"; ", k, v))
.collect::<Vec<String>>();
let exp_strig = format!(
"{}{}; ",
"{}export PATH=\"$PATH:{:?}\"; ",
exports.join(""),
format!("export PATH=\"$PATH:{:?}\"", export_paths.join(":"))
export_paths.join(":")
);

match Confirm::new()
Expand All @@ -855,11 +853,11 @@ pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> {
}
}

match Confirm::new()
if let Ok(true) = Confirm::new()
.with_prompt(t!("wizard.after_install.save_config.prompt"))
.interact()
{
Ok(true) => match config.save("eim_config.toml") {
match config.save("eim_config.toml") {
// TODO: make the name configurable
// TODO: make path configurable
Ok(_) => println!("{}", t!("wizard.after_install.config.saved")),
Expand All @@ -868,8 +866,7 @@ pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> {
t!("wizard.after_install.config.save_failed"),
err.to_string()
),
},
_ => (),
}
}

Ok(())
Expand Down

0 comments on commit 32d14de

Please sign in to comment.