a
This commit is contained in:
parent
42dc2d0b26
commit
114b1d1813
|
@ -2,6 +2,7 @@ use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Subcommand)]
|
#[derive(Debug, Clone, Subcommand)]
|
||||||
#[command(rename_all = "camelCase")]
|
#[command(rename_all = "camelCase")]
|
||||||
|
#[command(flatten_help = false)]
|
||||||
pub enum Commands {
|
pub enum Commands {
|
||||||
PrintExperience(crate::commands::print_experience::PrintExperienceArgs),
|
PrintExperience(crate::commands::print_experience::PrintExperienceArgs),
|
||||||
}
|
}
|
||||||
|
@ -9,22 +10,23 @@ pub enum Commands {
|
||||||
// TODO: add env vars back to this,
|
// TODO: add env vars back to this,
|
||||||
// clashes with multiple=false when one set as env and other as arg
|
// clashes with multiple=false when one set as env and other as arg
|
||||||
#[derive(Debug, Clone, clap::Args)]
|
#[derive(Debug, Clone, clap::Args)]
|
||||||
#[group(required = false, multiple = false)]
|
#[group(id = "journal_location", multiple = false)]
|
||||||
pub struct JournalFileArgs {
|
pub struct JournalLocationArgs {
|
||||||
// journal file is writable
|
// journal file is writable
|
||||||
// #[arg(group = "journal_file_args", global = true, long)]
|
#[arg(group = "journal_location", global = true, long)]
|
||||||
// pub journal_file: Option<String>,
|
pub journal_file: Option<String>,
|
||||||
|
|
||||||
// export file is read-only
|
// export file is read-only
|
||||||
#[arg(group = "journal_file", global = true, long)]
|
#[arg(group = "journal_location", global = true, long)]
|
||||||
pub psychonaut_export_file: Option<String>,
|
pub psychonaut_export_file: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
|
#[command(flatten_help = false)]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
pub command: Commands,
|
pub command: Commands,
|
||||||
|
|
||||||
#[command(flatten)]
|
#[command(flatten)]
|
||||||
pub journal_file_args: JournalFileArgs,
|
pub journal_location: Option<JournalLocationArgs>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ use crate::formatting::format_experience_title;
|
||||||
use crate::utils::load_journal;
|
use crate::utils::load_journal;
|
||||||
|
|
||||||
#[derive(Debug, Clone, clap::Args)]
|
#[derive(Debug, Clone, clap::Args)]
|
||||||
|
#[group(requires = "journal_location")]
|
||||||
pub struct PrintExperienceArgs {
|
pub struct PrintExperienceArgs {
|
||||||
#[arg(requires = "journal_file")]
|
|
||||||
pub experience_title: String,
|
pub experience_title: String,
|
||||||
|
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
|
@ -42,7 +42,9 @@ pub fn print_experience(
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let journal = load_journal(
|
let journal = load_journal(
|
||||||
&global_args
|
&global_args
|
||||||
.journal_file_args
|
.journal_location
|
||||||
|
.clone()
|
||||||
|
.unwrap()
|
||||||
.psychonaut_export_file
|
.psychonaut_export_file
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
|
|
@ -17,6 +17,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
||||||
match command {
|
match command {
|
||||||
args::Commands::PrintExperience(print_experience_args) => {
|
args::Commands::PrintExperience(print_experience_args) => {
|
||||||
|
println!("{:#?}", print_experience_args);
|
||||||
|
|
||||||
print_experience(&args, &print_experience_args)?
|
print_experience(&args, &print_experience_args)?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue