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

41 lines
883 B
Rust

use clap::{Parser, Subcommand};
use std::{fs, path::PathBuf};
use crate::{commands::list_entries::list_entries, md::Doc};
mod commands;
mod md;
mod utils;
#[derive(Debug, Parser)]
struct Cli {
#[arg(env)]
s10e_jrnl_file_loc: PathBuf,
#[command(subcommand)]
command: Option<Command>,
}
#[derive(Debug, Subcommand)]
enum Command {
#[command(aliases = ["l", "ls", "list"])]
ListEntries,
Add,
}
fn main() {
let cli = Cli::parse();
println!("Hello, world!");
println!("cli: {cli:#?}");
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);
}
}
}