use clap::{ArgAction, Args, Parser, Subcommand};
use color_print::cstr;
use std::path::PathBuf;
#[cfg(not(target_os = "windows"))]
const EXAMPLES: &str = cstr!(
"<bold><underline>Interactive mode:</underline></bold>
Run without arguments or with a single path argument to enter interactive mode.
<bold><underline>Examples:</underline></bold>
seednaut
seednaut list /path/to/backup
echo $MY_MNEMONIC | seednaut list /path/to/backup
seednaut inspect \"/path/to/other backup\" 1 3
seednaut verify /path/to/backup
seednaut help extract
seednaut extract /path/to/backup --match \"camera\" --export --out ./restore
"
);
#[cfg(target_os = "windows")]
const EXAMPLES: &str = cstr!(
"<bold><underline>Interactive mode:</underline></bold>
Run without arguments or with a single path argument to enter interactive mode.
<bold><underline>Examples:</underline></bold>
seednaut
seednaut list C:\\path\\to\\backup
echo %MY_MNEMONIC% | seednaut list C:\\path\\to\\backup
seednaut inspect \"C:\\path\\to\\other backup\" 1 3
seednaut verify C:\\path\\to\\backup
seednaut help extract
seednaut extract C:\\path\\to\\backup --match \"camera\" --export --out .\\restore
"
);
#[derive(Parser, Debug)]
#[command(author, version, about)]
#[command(disable_help_flag = true)]
#[command(after_help = EXAMPLES)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
#[arg(long, short, action = ArgAction::HelpLong)]
pub help: Option<bool>,
}
#[derive(Subcommand, Debug, Clone)]
pub enum Command {
#[command(arg_required_else_help = true)]
List(SnapshotSelector),
#[command(arg_required_else_help = true)]
Inspect(SnapshotSelector),
#[command(arg_required_else_help = true)]
Verify(SnapshotSelector),
#[command(arg_required_else_help = true)]
Extract(ExtractArgs),
}
#[derive(Args, Debug, Clone)]
pub struct SnapshotSelector {
pub path: PathBuf,
#[arg(required = false)]
pub snapshots: Vec<u32>,
}
#[derive(Args, Debug, Clone)]
pub struct ExtractArgs {
#[command(flatten)]
pub selector: SnapshotSelector,
#[arg(short, long = "out")]
pub out_dir: PathBuf,
#[arg(short = 'm', long = "match")]
pub pattern_str: Option<String>,
#[arg(short, long)]
pub export: bool,
}