diff --git a/journal_cli/src/args.rs b/journal_cli/src/args.rs index 72ef10b..a6dae2f 100644 --- a/journal_cli/src/args.rs +++ b/journal_cli/src/args.rs @@ -2,6 +2,7 @@ use clap::{Parser, Subcommand}; #[derive(Debug, Clone, Subcommand)] #[command(rename_all = "camelCase")] +#[command(flatten_help = false)] pub enum Commands { PrintExperience(crate::commands::print_experience::PrintExperienceArgs), } @@ -9,22 +10,23 @@ pub enum Commands { // TODO: add env vars back to this, // clashes with multiple=false when one set as env and other as arg #[derive(Debug, Clone, clap::Args)] -#[group(required = false, multiple = false)] -pub struct JournalFileArgs { +#[group(id = "journal_location", multiple = false)] +pub struct JournalLocationArgs { // journal file is writable - // #[arg(group = "journal_file_args", global = true, long)] - // pub journal_file: Option, + #[arg(group = "journal_location", global = true, long)] + pub journal_file: Option, // export file is read-only - #[arg(group = "journal_file", global = true, long)] + #[arg(group = "journal_location", global = true, long)] pub psychonaut_export_file: Option, } #[derive(Debug, Parser)] +#[command(flatten_help = false)] pub struct Args { #[command(subcommand)] pub command: Commands, #[command(flatten)] - pub journal_file_args: JournalFileArgs, + pub journal_location: Option, } diff --git a/journal_cli/src/commands/print_experience.rs b/journal_cli/src/commands/print_experience.rs index b359dda..4b48fe0 100644 --- a/journal_cli/src/commands/print_experience.rs +++ b/journal_cli/src/commands/print_experience.rs @@ -8,8 +8,8 @@ use crate::formatting::format_experience_title; use crate::utils::load_journal; #[derive(Debug, Clone, clap::Args)] +#[group(requires = "journal_location")] pub struct PrintExperienceArgs { - #[arg(requires = "journal_file")] pub experience_title: String, #[arg(long)] @@ -42,7 +42,9 @@ pub fn print_experience( ) -> Result<(), Box> { let journal = load_journal( &global_args - .journal_file_args + .journal_location + .clone() + .unwrap() .psychonaut_export_file .clone() .unwrap(), diff --git a/journal_cli/src/main.rs b/journal_cli/src/main.rs index 11340a0..c0a7ff9 100644 --- a/journal_cli/src/main.rs +++ b/journal_cli/src/main.rs @@ -17,6 +17,8 @@ fn main() -> Result<(), Box> { match command { args::Commands::PrintExperience(print_experience_args) => { + println!("{:#?}", print_experience_args); + print_experience(&args, &print_experience_args)? } }