∅:D[
11.70] → [
10.141:198]
B:BD[
10.141] → [
10.141:198]
B:BD[
10.198] → [
11.71:122]
pub fn read_config(configfile: &str) -> Result<Config, io::Error> {
// XXX: read config and potentially retrun io::Error
Ok(Config { fpath: String::from(configfile) })
impl Config {
pub fn new(mut args : env::Args) -> Result<Config, &'static str> {
args.next(); // skip program name (or assert that it's the correct thing?)
let action_cli = args.next().expect("no action");
let action = if action_cli.contains("list") {
Action::List
} else if action_cli.contains("edit") {
Action::Edit
} else if action_cli.contains("show") {
Action::Show
} else {
Action::List // or do nothing or panic // XXX: already panicking above
};
let config_str = match env::var("TN_CONFIG") {
Ok(c) => c,
Err(_) => String::from("/home/frank/.tn"),
};
Ok(Config {
fpath: String::from(config_str),
action: action,
})
}