Skip to content

Instantly share code, notes, and snippets.

@jabgibson
Created February 20, 2019 20:29
Show Gist options
  • Save jabgibson/3b5535421e34b202266bb805fc323dcc to your computer and use it in GitHub Desktop.
Save jabgibson/3b5535421e34b202266bb805fc323dcc to your computer and use it in GitHub Desktop.
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