Skip to content

Commit 1103415

Browse files
committed
fix(cli): fix trivially wrong flags
1 parent a0b5beb commit 1103415

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

src/cli.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
use std::{ffi::OsString, path::PathBuf};
77

8-
use clap::Parser;
8+
use clap::{ArgAction, Parser};
99

1010
#[derive(Parser, Debug)]
1111
#[clap(version, name = "uutils AWK")]
@@ -14,7 +14,7 @@ pub struct Args {
1414
// POSIX
1515
pub code: OsString,
1616
#[arg(short = 'f', long)]
17-
pub file: Option<PathBuf>,
17+
pub file: Vec<PathBuf>,
1818
#[arg(short = 'F', long)]
1919
pub field_separator: Option<OsString>,
2020
#[arg(short = 'v', long, value_parser = parse_kv)]
@@ -25,23 +25,23 @@ pub struct Args {
2525
pub traditional: bool,
2626
#[arg(short = 'C', long)]
2727
pub copyright: bool,
28-
#[arg(short = 'd', long)]
28+
#[arg(short = 'd', long, num_args = 0..=1, default_missing_value = "./awkvars.out")]
2929
pub dump_variables: Option<PathBuf>,
30-
#[arg(short = 'D', long)]
30+
#[arg(short = 'D', long, num_args = 0..=1)]
3131
pub debug: Option<PathBuf>,
3232
#[arg(short = 'e', long)]
33-
pub source: Vec<u8>,
33+
pub source: Vec<OsString>,
3434
#[arg(short = 'E', long)]
3535
pub exec: Option<PathBuf>,
3636
#[arg(short = 'g', long)]
3737
pub gen_pot: bool,
3838
#[arg(short = 'i', long)]
39-
pub include: Option<PathBuf>,
39+
pub include: Vec<PathBuf>,
4040
#[arg(short = 'I', long)]
4141
pub trace: bool,
4242
#[arg(short = 'l', long)]
4343
pub load: Vec<OsString>,
44-
#[arg(short = 'L', long)]
44+
#[arg(short = 'L', long, num_args = 0..=1, default_missing_value = "")]
4545
pub lint: Vec<String>,
4646
#[arg(short = 'M', long)]
4747
pub bignum: bool,
@@ -51,23 +51,25 @@ pub struct Args {
5151
pub use_lc_numeric: bool,
5252
#[arg(short = 'o', long, num_args = 0..=1, default_missing_value = "./awkprof.out")]
5353
pub pretty_print: Option<PathBuf>,
54-
#[arg(short = 'O', long, default_value_t = true)]
54+
#[arg(short = 'O', long, default_value_t = true, action = ArgAction::SetTrue)]
5555
pub optimize: bool,
5656
#[arg(short = 's', long = "no-optimize")]
5757
pub no_optimize: bool,
58-
#[arg(short = 'p', num_args = 0..=1, long)]
58+
#[arg(short = 'p', long, num_args = 0..=1, default_missing_value = "./awkprof.out")]
5959
pub profile: Option<PathBuf>,
6060
#[arg(short = 'P', long)]
6161
pub posix: bool,
62-
#[arg(short = 'r', long, default_value_t = true)]
62+
#[arg(short = 'r', long, default_value_t = true, action = ArgAction::SetTrue)]
6363
pub re_interval: bool,
6464
#[arg(short = 'S', long)]
6565
pub sandbox: bool,
6666
#[arg(short = 't', long)]
6767
pub lint_old: bool,
68+
#[arg(short = 'k', long, conflicts_with = "posix")]
69+
pub csv: bool,
6870
}
6971

7072
fn parse_kv(s: &str) -> Result<(String, String), String> {
7173
let (k, v) = s.split_once('=').ok_or("expected key=value")?;
72-
Ok((k.to_string(), v.trim_matches(['"', '\'']).to_string()))
74+
Ok((k.to_string(), v.to_string()))
7375
}

0 commit comments

Comments
 (0)