Skip to content

Instantly share code, notes, and snippets.

@bstrie
Created April 30, 2015 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bstrie/05dc5ef21b0274a64e98 to your computer and use it in GitHub Desktop.
Save bstrie/05dc5ef21b0274a64e98 to your computer and use it in GitHub Desktop.
extern crate serde;
use std::env;
use std::path::Path;
use serde::json;
fn main() {
let our_args: Vec<String> = std::env::args().collect();
let base_name = Path::new(&our_args[0])
.file_name().expect("Path is not a file")
.to_str().expect("File name is not valid Unicode");
let env_name = "installrunenv".to_owned() + base_name;
let json_str = env::var(&env_name)
.ok().expect("Environment variable is not set");
let new_args: Vec<String> = json::from_str(&json_str)
.ok().expect("JSON could not be parsed");
execv(new_args + &our_args[1..]);
}
fn execv(args: Vec<String>) {
println!("{:?}", args);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment