main: fill out argument structs
This commit is contained in:
103
src/main.rs
103
src/main.rs
@@ -3,19 +3,100 @@ use clap::Parser;
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
struct Args {
|
||||
// TODO:
|
||||
// - run over until succeeds
|
||||
// - run over until fails
|
||||
// - run over until stdout match (literal, regex)
|
||||
// - run over until stderr match (literal, regex)
|
||||
// - run over until other command succeeds
|
||||
// - run over until other command fails
|
||||
// - per run timeout
|
||||
// - global timeout
|
||||
// - max iterations
|
||||
// - sleep
|
||||
#[command(subcommand)]
|
||||
command: Command,
|
||||
|
||||
/// Global timeout in seconds
|
||||
#[arg(short='T', long, default_value = None)]
|
||||
timeout: Option<u64>,
|
||||
|
||||
/// Per-iteration timeout in seconds
|
||||
#[arg(short='t', long, default_value = None)]
|
||||
per_run_timeout: Option<u64>,
|
||||
|
||||
/// Maximum number of iterations
|
||||
#[arg(short, long, default_value = None)]
|
||||
max_iterations: Option<u64>,
|
||||
|
||||
/// Delay between iterations in seconds
|
||||
#[arg(short, long, default_value_t = 1)]
|
||||
delay: u64,
|
||||
|
||||
/// Consume stdin in it's entirety and propagate a copy to each command execution
|
||||
#[arg(long)]
|
||||
consume_stdin: bool,
|
||||
}
|
||||
|
||||
#[derive(clap::Subcommand, Debug)]
|
||||
enum Command {
|
||||
/// Run command multiple times until it succeeds
|
||||
UntilSucceeds {
|
||||
/// Command to run
|
||||
#[arg(required = true)]
|
||||
cmd: Vec<String>,
|
||||
},
|
||||
|
||||
/// Run command multiple times until it fails
|
||||
UntilFails {
|
||||
/// Command to run
|
||||
#[arg(required = true)]
|
||||
cmd: Vec<String>,
|
||||
},
|
||||
|
||||
/// Run command multiple times until its stdout matches a pattern
|
||||
UntilStdoutMatch {
|
||||
/// Command to run
|
||||
#[arg(required = true)]
|
||||
cmd: Vec<String>,
|
||||
|
||||
/// Pattern to match (literal)
|
||||
#[arg(long)]
|
||||
literal: Option<String>,
|
||||
|
||||
/// Pattern to match (regex)
|
||||
#[arg(long)]
|
||||
regex: Option<String>,
|
||||
},
|
||||
|
||||
/// Run command multiple times until its stderr matches a pattern
|
||||
UntilStderrMatch {
|
||||
/// Command to run
|
||||
#[arg(required = true)]
|
||||
cmd: Vec<String>,
|
||||
|
||||
/// Pattern to match (literal)
|
||||
#[arg(long)]
|
||||
literal: Option<String>,
|
||||
|
||||
/// Pattern to match (regex)
|
||||
#[arg(long)]
|
||||
regex: Option<String>,
|
||||
},
|
||||
|
||||
/// Run command multiple times until another command succeeds
|
||||
UntilOtherCommandSucceeds {
|
||||
/// Command to run
|
||||
#[arg(required = true)]
|
||||
cmd: Vec<String>,
|
||||
|
||||
/// Other command to check
|
||||
#[arg(long, required = true)]
|
||||
other_cmd: Vec<String>,
|
||||
},
|
||||
|
||||
/// Run command multiple times until another command fails
|
||||
UntilOtherCommandFails {
|
||||
/// Command to run
|
||||
#[arg(required = true)]
|
||||
cmd: Vec<String>,
|
||||
|
||||
/// Other command to check
|
||||
#[arg(long, required = true)]
|
||||
other_cmd: Vec<String>,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let args = Args::parse();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user