-
-
Save bstrie/05dc5ef21b0274a64e98 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
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