use std::path::PathBuf;
use clap::{Args, Subcommand};
use crate::cli::limits::LimitArg;
#[derive(Debug, Subcommand)]
pub enum ExtractCommand {
#[command(
about = "Extract protocol-neutral event rows from waveform signals.",
long_about = r#"Extract protocol-neutral event rows from waveform signals.
Behavior:
- Selects edge-only event timestamps with --on.
- Always samples --when and --payload at the pre-edge sample point.
- In single-source mode, --on, --when, and --payload define one source named by --name or "transfer".
- In source-file mode, --source provides one or more sources and conflicts with --name, --on, --when, and --payload.
- Contract for source-file mode is defined by `wavepeek schema --input`.
- JSON and JSONL rows include time, sample_time, source, and ordered payload values.
Use this command to extract synchronous handshakes or transfer-like rows without joining property and value output outside wavepeek."#,
after_long_help = "See also:\n wavepeek docs show commands/extract"
)]
Generic(GenericArgs),
}
#[derive(Debug, Args)]
pub struct GenericArgs {
#[arg(long, value_name = "FILE", help_heading = "Input options")]
pub waves: PathBuf,
#[arg(
long,
value_name = "FILE",
conflicts_with_all = ["name", "on", "when", "payload"],
help_heading = "Input options"
)]
pub source: Option<PathBuf>,
#[arg(long, help_heading = "Selection options")]
pub from: Option<String>,
#[arg(long, help_heading = "Selection options")]
pub to: Option<String>,
#[arg(long, help_heading = "Selection options")]
pub scope: Option<String>,
#[arg(long, help_heading = "Selection options")]
pub name: Option<String>,
#[arg(long, help_heading = "Selection options")]
pub on: Option<String>,
#[arg(long, help_heading = "Selection options")]
pub when: Option<String>,
#[arg(
long,
value_delimiter = ',',
num_args = 1..,
value_name = "SIGNAL[,SIGNAL...]",
help_heading = "Selection options"
)]
pub payload: Option<Vec<String>>,
#[arg(long, default_value = "50", help_heading = "Output options")]
pub max: LimitArg,
#[arg(long, help_heading = "Output options")]
pub abs: bool,
#[arg(long, help_heading = "Output options")]
pub json: bool,
#[arg(long, conflicts_with = "json", help_heading = "Output options")]
pub jsonl: bool,
}