Skip to content

Commit

Permalink
Allow Cargo workspace config file (#595)
Browse files Browse the repository at this point in the history
* feat: Allow Cargo workspace config file

* docs: Update changelog
  • Loading branch information
SergioGasquez authored Feb 21, 2024
1 parent 3ab8614 commit 14befdc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- Allow config file to live in parent folder (#595)

### Fixed
- Change the `hard_reset` sequence to fix Windows issues (#594)
Expand Down
2 changes: 1 addition & 1 deletion cargo-espflash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ The configuration file allows you to define various parameters for your applicat

You can have a local and/or a global configuration file:

- For local configurations, store the file under the current working directory with the name `espflash.toml`
- For local configurations, store the file under the current working directory or in the parent directory (to support Cargo workspaces) with the name `espflash.toml`
- Global file location differs based on your operating system:
- Linux: `$HOME/.config/espflash/espflash.toml`
- macOS: `$HOME/Library/Application Support/rs.esp.espflash/espflash.toml`
Expand Down
2 changes: 1 addition & 1 deletion espflash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ The configuration file allows you to define various parameters for your applicat

You can have a local and/or a global configuration file:

- For local configurations, store the file under the current working directory with the name `espflash.toml`
- For local configurations, store the file under the current working directory or in the parent directory (to support Cargo workspaces) with the name `espflash.toml`
- Global file location differs based on your operating system:
- Linux: `$HOME/.config/espflash/espflash.toml`
- macOS: `$HOME/Library/Application Support/rs.esp.espflash/espflash.toml`
Expand Down
6 changes: 6 additions & 0 deletions espflash/src/cli/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ impl Config {
if local_config.exists() {
return Ok(local_config);
}
if let Some(parent_folder) = std::env::current_dir()?.parent() {
let workspace_config = parent_folder.join("espflash.toml");
if workspace_config.exists() {
return Ok(workspace_config);
}
}

let project_dirs = ProjectDirs::from("rs", "esp", "espflash").unwrap();
let global_config = project_dirs.config_dir().join("espflash.toml");
Expand Down

0 comments on commit 14befdc

Please sign in to comment.