ok we can main thats nice
This commit is contained in:
31
src/main.rs
31
src/main.rs
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user