use super::parsing::parse_key_val;
use camino::Utf8PathBuf;
use clap::{Args, Parser, Subcommand};
#[derive(Debug, Parser)]
#[command(
name = "Jango",
author,
version,
about,
long_about = None,
help_template = "\
{before-help}{name} {version}
{author-with-newline}{about-with-newline}
{usage-heading} {usage}
{all-args}{after-help}"
)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Subcommand)]
#[command(help_template(
"\
{name}
{about-with-newline}
{usage-heading} {usage}
{all-args}"
))]
pub enum Command {
#[command(arg_required_else_help = true, visible_alias = "a")]
Args(CommandLineArgs),
#[command(arg_required_else_help = true, visible_alias = "md")]
Markdown(MarkdownArgs),
}
#[derive(Debug, Args)]
#[command(help_template(
"\
{name}
{about-with-newline}
{usage-heading} {usage}
{all-args}"
))]
pub struct CommandLineArgs {
#[arg(short, long)]
pub escape: bool,
#[arg(short, long, value_parser = parse_key_val::<String, String>)]
pub data: Option<Vec<(String, String)>>,
#[arg(value_hint = clap::ValueHint::FilePath)]
pub template: Utf8PathBuf,
pub output: Option<Utf8PathBuf>,
}
#[derive(Debug, Args)]
#[command(help_template(
"\
{name}
{about-with-newline}
{usage-heading} {usage}
{all-args}"
))]
pub struct MarkdownArgs {
#[arg(short, long = "inline")]
pub inline_html: bool,
#[arg(value_hint = clap::ValueHint::FilePath)]
pub template: Utf8PathBuf,
#[arg(value_hint = clap::ValueHint::FilePath)]
pub input: Utf8PathBuf,
pub output: Option<Utf8PathBuf>,
}