1use std::env;
2
3const DEFAULT_MESSAGE: &str = "Earthquake!!! This is an emergency commit";
4
5pub struct Config {
7 pub commit_message: String,
9}
10
11impl Config {
12 pub fn new(mut args: env::Args) -> (Self, Option<&'static str>) {
14 args.next();
16
17 let commit_message = match args.next() {
18 Some(s) => s,
19 None => DEFAULT_MESSAGE.to_owned(),
20 };
21
22 let mut warning = Option::None;
23 if args.len() > 0 {
24 warning = Option::Some("Warning: Too many arguments passed. Arguments after commit message are being ignored");
25 }
26
27 (Self { commit_message }, warning)
28 }
29}