use ::std::time::Duration;
use ::clap::Parser;
use ::parse_duration0::parse as parse_dur;
use crate::common::CommandArgs;
#[derive(Parser, Debug)]
#[command(
name = "locked",
about = "Do not start a command until a given lock is released."
)]
pub struct LockedArgs {
#[arg(short = 'f', long = "lock-key", default_value = "%{pwd}.lock")]
pub lock_key: String,
#[arg(value_parser = parse_dur, short = 't', long = "timeout", default_value = "15 min")]
pub timeout: Duration,
#[arg(short = 'p', long = "progress")]
pub show_progress: bool,
#[arg(short = 'r', long = "read")]
pub read: bool,
#[arg(short = 's', long = "show")]
pub show: bool,
#[arg(long = "unlock")]
pub unlock: bool,
#[command(subcommand)]
pub cmd: CommandArgs,
}
#[test]
fn test_cli_args() {
LockedArgs::try_parse_from(&["cmd", "-t=5 min", "ls"]).unwrap();
}