Created
March 17, 2018 18:18
-
-
Save 0x5d/a62cba9afab3819d68b67b7ea5229d88 to your computer and use it in GitHub Desktop.
This file contains hidden or 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; | |
struct Config { mode: String, port: String } | |
fn main() { | |
let args: Vec<_> = env::args().collect(); | |
let config = parse_config(&args); | |
} | |
fn parse_config(args: &Vec<String>) -> Config { | |
let default_mode = &"ping".to_string(); | |
let mode = args.get(1).unwrap_or(default_mode); | |
let default_port = &"3000".to_string(); | |
let port = args.get(2).unwrap_or(default_port); | |
Config { mode: *mode, port: *port } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment