cli arguments

This commit is contained in:
Andrei Stoica 2024-03-06 14:31:53 -05:00
parent bce8f1e4b8
commit e4be0fb471
2 changed files with 7 additions and 4 deletions

View File

@ -10,4 +10,8 @@ pub struct Args {
/// show current config file
#[arg(short = 'C', long)]
pub current_config: bool,
/// veiw previous day's notes
#[arg(short = 'p', long, default_value_t = 0)]
pub previous: u16,
}

View File

@ -15,10 +15,9 @@ use std::fs;
use std::path::Path;
use std::process::Command;
//TODO refactor creating new file
fn main() {
let args = Args::parse();
println!("previous = {}", args.previous);
let expected_cfg_files = match Config::expected_locations() {
Ok(cfg_files) => cfg_files,
@ -113,8 +112,8 @@ fn main() {
Ok(todo_file) => todo_file.file.path(),
};
Command::new(cfg.editor)
Command::new(&cfg.editor)
.args([current_file])
.status()
.expect(format!("failed to launch editor {}", "vim").as_str());
.expect(format!("failed to launch editor {}", &cfg.editor).as_str());
}