flagon-io/hello

public

Greets people from the command line. The sample repository for g1t.

hello/src/main.rs

14 lines409 bytesCodeBlame
1use std::env;
2
3use hello::{greeting, parse_args, shout};
4
5fn main() {
6 let options = parse_args(env::args().skip(1));
7 // The name given, or whoever is signed in.
8 let name = options
9 .name
10 .or_else(|| env::var("USER").ok())
11 .unwrap_or_else(|| "world".to_owned());
12 let message = greeting(&name);
13 println!("{}", if options.shout { shout(&message) } else { message });
14}