Skip to content

Commit 6ad74e9

Browse files
refactor: read all env vars
- Skip name after first pass - Print to stderr instead of stdout
1 parent 80dfcb8 commit 6ad74e9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,17 @@ fn main() {
1111
} else {
1212
println!("Hello, world!");
1313
}
14+
// read remaining env vars other than NAME
15+
for item in dotenvy::dotenv_iter().unwrap() {
16+
let (key, value) = item.unwrap();
17+
if key != "NAME" {
18+
println!("{}: {}", key, value);
19+
}
20+
}
1421
},
1522
Err(_) => {
16-
// If .env file could not be loaded or vars don't match, print "Hello, world!"
17-
println!("Hello, world!");
23+
// If .env file could not be loaded or vars don't match, print to stderr
24+
eprintln!("Error reading env vars!");
1825
}
1926
}
2027
}

0 commit comments

Comments
 (0)