use ::std::time::Duration;
use ::clap::StructOpt;
use ::parse_duration0::parse as parse_dur;
use crate::common::CommandArgs;
#[derive(StructOpt, Debug)]
#[structopt(
name = "cached",
about = "Cache the output of a command for a given duration, running it only if there is no cache or it has expired. Stderr is only shown on first run."
)]
pub struct CachedArgs {
#[structopt(parse(try_from_str = parse_dur), short = 'd', long = "duration", default_value = "15 min")]
pub duration: Duration,
#[structopt(
short = 'k',
long = "key",
default_value = "%{pwd}_%{env}_%{cmd}.cache",
help = "The key to use for the cache. Can use %{pwd}, %{env} and %{cmd} placeholders. See long --help for more.",
long_help = "The key to use for the cache. Can use %{pwd}, %{env} and %{cmd} placeholders.{n}{n}* %{git_uncommitted} contains a hash of the git index and unstaged files.{n}* %{git_head} contains the hash of the git head commit.{n}* %{git} is the combination of all git state.{n}* %{env} only contains non-inherited env."
)]
pub key: String,
#[structopt(short = 's', long)]
pub no_cached_output: bool,
#[structopt(short = 'v', long)]
pub verbose: bool,
#[structopt(subcommand)]
pub cmd: CommandArgs,
}
#[test]
fn test_cli_args() {
use clap::IntoApp;
CachedArgs::into_app().debug_assert()
}