nix-configs/programs/jrnl/src/main.rs

42 lines
883 B
Rust
Raw Normal View History

2024-04-16 22:06:12 +02:00
use clap::{Parser, Subcommand};
use std::{fs, path::PathBuf};
2024-04-20 20:07:07 +02:00
use crate::{commands::list_entries::list_entries, md::Doc};
2024-04-16 22:06:12 +02:00
mod commands;
mod md;
mod utils;
2024-04-16 22:06:12 +02:00
#[derive(Debug, Parser)]
struct Cli {
#[arg(env)]
s10e_jrnl_file_loc: PathBuf,
#[command(subcommand)]
command: Option<Command>,
}
#[derive(Debug, Subcommand)]
enum Command {
2024-04-20 20:07:07 +02:00
#[command(aliases = ["l", "ls", "list"])]
ListEntries,
2024-04-16 22:06:12 +02:00
Add,
}
2024-04-16 21:37:01 +02:00
fn main() {
2024-04-16 22:06:12 +02:00
let cli = Cli::parse();
2024-04-16 21:37:01 +02:00
println!("Hello, world!");
println!("cli: {cli:#?}");
2024-04-20 20:07:07 +02:00
match cli.command {
Some(Command::ListEntries) => list_entries(cli.s10e_jrnl_file_loc.clone()),
Some(Command::Add) => todo!(),
None => {
// TODO: handle btter
let file = fs::read_to_string(cli.s10e_jrnl_file_loc).unwrap();
let doc = Doc::new(&file);
dbg!(doc);
}
}
}