Skip to content

Commit

Permalink
BREAKING CHANGE: throw error when a path points to something non-exis…
Browse files Browse the repository at this point in the history
…tent
  • Loading branch information
brodo committed Nov 4, 2022
1 parent fbf7a29 commit 0324046
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Better error messages
- Support for multiple config files

### Changed

- Throw error if a JSON path is provided, that does not point to a thing


## [1.2.0] - 2022-11-03

### Added
Expand Down
11 changes: 10 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ fn main() {

let mut env_vars: HashMap<String, String> = HashMap::new();


for (i, file_name) in args.config_files.iter().enumerate() {
let Ok(mut file) = File::open(file_name) else {
cmd.error(
Expand All @@ -61,6 +60,16 @@ fn main() {
if file.read_to_string(&mut contents).is_ok() {
match parse_and_extract(&contents, json_path) {
Ok(val) => {
if val.is_empty() {
cmd.error(
ErrorKind::InvalidValue,
format!(
"There is nothing in file '{}' at path '{}'",
file_name, json_path
),
)
.exit();
}
add_values_to_map(&val, args.expand, &mut env_vars);
}
Err(e) => cmd
Expand Down

0 comments on commit 0324046

Please sign in to comment.