Created
February 20, 2019 20:29
-
-
Save jabgibson/3b5535421e34b202266bb805fc323dcc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::env; | |
use std::fs; | |
use std::process; | |
fn main() { | |
let creds_file = match env::var("AWS_CREDS_FILE") { | |
Ok(val) => val, | |
Err(_) => { | |
println!("an env variable of AWS_CREDS_FIlE is required"); | |
process::exit(1); | |
}, | |
}; | |
let file_content = match fs::read_to_string(creds_file) { | |
Ok(val) => val, | |
Err(err) => { | |
println!("{}", err); | |
process::exit(1); | |
} | |
}; | |
for line in file_content.lines() { | |
let sections : Vec<&str> = line.split(" ").collect::<Vec<&str>>(); | |
if sections.len() == 3 { | |
let key = sections[0].to_uppercase(); | |
let key = key.trim(); | |
let val = sections[2].trim(); | |
println!("export {}={}", key, val) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment