From 6448fc39ae971ff510fa781f7b13ec81b4c65c25 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Thu, 29 Dec 2022 13:05:50 +0100 Subject: [PATCH 01/10] =?UTF-8?q?docs:=20=F0=9F=93=9D=20Update=20esp-idf-v?= =?UTF-8?q?ersion=20documentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 7866546..f8266b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -60,7 +60,9 @@ pub struct InstallOpts { /// Target triple of the host. #[arg(short = 'd', long, required = false, value_parser = ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "x86_64-pc-windows-msvc", "x86_64-pc-windows-gnu" , "x86_64-apple-darwin" , "aarch64-apple-darwin"])] pub default_host: Option, - /// ESP-IDF version to install. If empty, no esp-idf is installed. Version format: + /// ESP-IDF version to install. If empty, no ESP-IDF is installed. ESP-IDF installation can also be managed by esp-idf-sys(https://github.com/esp-rs/esp-idf-sys). + /// + /// Version format: /// /// - `commit:`: Uses the commit `` of the `esp-idf` repository. /// From eae6ff61ef5c02ca82218fa7e4fd4ff7e3586f93 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Thu, 29 Dec 2022 13:12:56 +0100 Subject: [PATCH 02/10] =?UTF-8?q?docs:=20=F0=9F=93=9D=20Update=20profile-m?= =?UTF-8?q?inimal=20documentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index f8266b3..3124a1d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -92,7 +92,10 @@ pub struct InstallOpts { /// Nightly Rust toolchain version. #[arg(short = 'n', long, default_value = "nightly")] pub nightly_version: String, - /// Minifies the installation. + /// Minifies the installation. + /// + /// This will install a reduced version of LLVM, delete the folder where all the assets are downloaded, + /// and, if installing ESP-IDF, delete some unncessary folders like docs and examples. #[arg(short = 'm', long)] pub profile_minimal: bool, /// Comma or space separated list of targets [esp32,esp32s2,esp32s3,esp32c2,esp32c3,all]. From 829820f4c8930da2aef2621f93d81d86b8bed007 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Thu, 29 Dec 2022 13:44:43 +0100 Subject: [PATCH 03/10] =?UTF-8?q?docs:=20=F0=9F=93=9D=20Update=20export=5F?= =?UTF-8?q?file=20documentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 3124a1d..099733d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,7 +77,7 @@ pub struct InstallOpts { /// When using this option, `ldproxy` crate will also be installed. #[arg(short = 'e', long, required = false)] pub esp_idf_version: Option, - /// Destination of the generated export file. + /// Relative or full path of the generated export file. If no path is provided, the file will be generated under home directory (https://docs.rs/dirs/latest/dirs/fn.home_dir.html). #[arg(short = 'f', long)] pub export_file: Option, /// Comma or space list of extra crates to install. From 6aae03d230a4e8a004c3fc4decf1a9f1d2afe8b4 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Thu, 29 Dec 2022 13:00:26 +0000 Subject: [PATCH 04/10] =?UTF-8?q?feat:=20=E2=9C=A8=20Check=20if=20the=20pr?= =?UTF-8?q?ovided=20export-file=20is=20a=20file=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/error.rs | 6 ++++++ src/main.rs | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/error.rs b/src/error.rs index 9b75c87..3d4bf92 100644 --- a/src/error.rs +++ b/src/error.rs @@ -84,4 +84,10 @@ pub enum Error { emoji::ERROR )] FailedToRemoveFile(String), + #[diagnostic(code(espup::wrong_export_file))] + #[error( + "{} Wrong export file destination: '{0}'. Please, use an absolte or releative path (including the file and its extension).", + emoji::ERROR + )] + WrongExportFile(String), } diff --git a/src/main.rs b/src/main.rs index 099733d..a3efe71 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ use log::{debug, info, warn}; use miette::Result; use std::{ collections::HashSet, - fs::{remove_dir_all, remove_file, File}, + fs::{metadata, remove_dir_all, remove_file, File}, io::Write, path::PathBuf, }; @@ -428,6 +428,10 @@ fn clear_dist_folder() -> Result<(), Error> { /// Returns the absolute path to the export file, uses the DEFAULT_EXPORT_FILE if no arg is provided. fn get_export_file(export_file: Option) -> Result { if let Some(export_file) = export_file { + let metadata = export_file.metadata()?; + if !metadata.is_file() { + return Err(Error::WrongExportFile(export_file.display().to_string())); + } if export_file.is_absolute() { Ok(export_file) } else { From fc38f3330c2b7c97a0688f19b30b6340bee13239 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Thu, 29 Dec 2022 13:03:21 +0000 Subject: [PATCH 05/10] =?UTF-8?q?docs:=20=F0=9F=93=9D=20Update=20install?= =?UTF-8?q?=20usage=20section?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a8d1f22..7022bbc 100644 --- a/README.md +++ b/README.md @@ -149,8 +149,12 @@ Options: -d, --default-host Target triple of the host + [possible values: x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-pc-windows-msvc, x86_64-pc-windows-gnu, x86_64-apple-darwin, aarch64-apple-darwin] + -e, --esp-idf-version - ESP-IDF version to install. If empty, no esp-idf is installed. Version format: + ESP-IDF version to install. If empty, no ESP-IDF is installed. ESP-IDF installation can also be managed by esp-idf-sys(https://github.com/esp-rs/esp-idf-sys). + + Version format: - `commit:`: Uses the commit `` of the `esp-idf` repository. @@ -165,7 +169,7 @@ Options: When using this option, `ldproxy` crate will also be installed. -f, --export-file - Destination of the generated export file + Relative or full path of the generated export file. If no path is provided, the file will be generated under home directory (https://docs.rs/dirs/latest/dirs/fn.home_dir.html) -c, --extra-crates Comma or space list of extra crates to install @@ -188,7 +192,9 @@ Options: [default: nightly] -m, --profile-minimal - Minifies the installation + Minifies the installation. + + This will install a reduced version of LLVM, delete the folder where all the assets are downloaded, and, if installing ESP-IDF, delete some unncessary folders like docs and examples. -t, --targets Comma or space separated list of targets [esp32,esp32s2,esp32s3,esp32c2,esp32c3,all] From 8d9e5f13339cc63b3590256a1010816291393a3f Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Thu, 29 Dec 2022 13:04:15 +0000 Subject: [PATCH 06/10] =?UTF-8?q?docs:=20=F0=9F=93=9D=20Update=20update=20?= =?UTF-8?q?usage=20section?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7022bbc..0e46c5e 100644 --- a/README.md +++ b/README.md @@ -229,7 +229,7 @@ Usage: espup update [OPTIONS] Options: -d, --default-host - Target triple of the host + Target triple of the host [possible values: x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-pc-windows-msvc, x86_64-pc-windows-gnu, x86_64-apple-darwin, aarch64-apple-darwin] -l, --log-level Verbosity level of the logs [default: info] [possible values: debug, info, warn, error] -v, --toolchain-version From 67e03c878ceeb7639d30a253eac305327c6568a7 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Thu, 29 Dec 2022 13:12:15 +0000 Subject: [PATCH 07/10] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20clippy=20warn?= =?UTF-8?q?ings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index a3efe71..9e4d61b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ use log::{debug, info, warn}; use miette::Result; use std::{ collections::HashSet, - fs::{metadata, remove_dir_all, remove_file, File}, + fs::{remove_dir_all, remove_file, File}, io::Write, path::PathBuf, }; From 87863fe8f884d7319f754e4a476a0f3255cf479c Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Fri, 30 Dec 2022 10:10:18 +0100 Subject: [PATCH 08/10] =?UTF-8?q?fix:=20=E2=9C=85=20Fix=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9e4d61b..4c55d4a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -428,8 +428,7 @@ fn clear_dist_folder() -> Result<(), Error> { /// Returns the absolute path to the export file, uses the DEFAULT_EXPORT_FILE if no arg is provided. fn get_export_file(export_file: Option) -> Result { if let Some(export_file) = export_file { - let metadata = export_file.metadata()?; - if !metadata.is_file() { + if export_file.is_dir() { return Err(Error::WrongExportFile(export_file.display().to_string())); } if export_file.is_absolute() { From 1a21ef9593fd573b22cbcff38e8637ebcbdd9432 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Fri, 30 Dec 2022 10:25:43 +0100 Subject: [PATCH 09/10] =?UTF-8?q?test:=20=F0=9F=A7=AA=20Add=20a=20test=20c?= =?UTF-8?q?ase:=20Export=20file=20path=20is=20a=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.rs b/src/main.rs index 4c55d4a..7b542e0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -516,5 +516,7 @@ mod tests { get_export_file(Some(PathBuf::from("/home/user/export.sh"))), Ok(export_file) )); + // Path is a directory instead of a file + assert!(get_export_file(Some(home_dir)).is_err()); } } From 4fd66bdc3cb8823f8593a79ddf47c24bf04754fc Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Fri, 30 Dec 2022 10:38:47 +0100 Subject: [PATCH 10/10] =?UTF-8?q?docs:=20=F0=9F=93=9D=20Update=20export=5F?= =?UTF-8?q?file=20documentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0e46c5e..be70eab 100644 --- a/README.md +++ b/README.md @@ -169,7 +169,7 @@ Options: When using this option, `ldproxy` crate will also be installed. -f, --export-file - Relative or full path of the generated export file. If no path is provided, the file will be generated under home directory (https://docs.rs/dirs/latest/dirs/fn.home_dir.html) + Relative or full path for the export file that will be generated. If no path is provided, the file will be generated under home directory (https://docs.rs/dirs/latest/dirs/fn.home_dir.html) -c, --extra-crates Comma or space list of extra crates to install diff --git a/src/main.rs b/src/main.rs index 7b542e0..d61f4b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,7 +77,7 @@ pub struct InstallOpts { /// When using this option, `ldproxy` crate will also be installed. #[arg(short = 'e', long, required = false)] pub esp_idf_version: Option, - /// Relative or full path of the generated export file. If no path is provided, the file will be generated under home directory (https://docs.rs/dirs/latest/dirs/fn.home_dir.html). + /// Relative or full path for the export file that will be generated. If no path is provided, the file will be generated under home directory (https://docs.rs/dirs/latest/dirs/fn.home_dir.html). #[arg(short = 'f', long)] pub export_file: Option, /// Comma or space list of extra crates to install.