ok we can main thats nice

This commit is contained in:
Bel LaPointe
2023-11-27 09:12:57 -07:00
parent f82418db47
commit 482eba9fd4
3 changed files with 210 additions and 1 deletions

View File

@@ -3,9 +3,38 @@ use std::io::{Read, Write};
use std::fs::File;
use std::time::{SystemTime, UNIX_EPOCH, Duration};
use std::ops::Add;
use clap::Parser;
#[derive(Debug, Parser)]
struct Flags {
#[arg(short = 'f', long = "file")]
f: String,
#[arg(short = 'l', long = "log")]
log: bool,
#[arg(short = 'a', long = "add")]
add: Option<String>,
#[arg(short = 't', long = "tag")]
tag: Option<String>,
}
fn main() {
println!("Hello, world!");
let flags = Flags::parse();
match flags.add.clone() {
Some(add) => {
let tag = flags.tag.clone().unwrap_or("".to_string());
let mut tsheet = load(flags.f.clone()).unwrap();
tsheet.add(add, tag);
save(flags.f.clone(), tsheet).unwrap();
},
None => {},
};
println!("{:?}", flags);
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]