mirror of
https://forge.katzen.cafe/schrottkatze/nix-configs.git
synced 2024-11-05 23:26:23 +01:00
42 lines
883 B
Rust
42 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);
|
|
}
|
|
}
|
|
}
|