Skip to content

Commit

Permalink
m4: Rename CLI arguments and add multiple files support there
Browse files Browse the repository at this point in the history
  • Loading branch information
kellpossible committed Jun 15, 2024
1 parent bcfa3f5 commit 233311d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions m4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,21 @@ pub struct Args {
///
/// Define `name` to `val` or to `null` if `=val` is omitted.
#[arg(short = 'D', long)]
pub defines: Vec<ArgumentDefine>,
pub define: Vec<ArgumentDefine>,
// Undefine `name`.
#[arg(short = 'U', long)]
pub undefines: Vec<ArgumentName>,
pub undefine: Vec<ArgumentName>,
/// Whether to read input from a file.
pub file: Option<PathBuf>,
pub files: Vec<PathBuf>,
}

impl Default for Args {
fn default() -> Self {
Self {
line_synchronization: false,
defines: Vec::default(),
undefines: Vec::default(),
file: None,
define: Vec::default(),
undefine: Vec::default(),
files: Vec::default(),
}
}
}
Expand All @@ -115,7 +115,7 @@ pub fn run<STDOUT: Write, STDERR: Write>(
stderr: &mut STDERR,
args: Args,
) -> crate::error::Result<()> {
let result = if let Some(file_path) = args.file {
let result = if let Some(file_path) = args.files.into_iter().next() {
lexer::process_streaming(
State::default(),
evaluate::evaluate,
Expand Down
2 changes: 1 addition & 1 deletion m4/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn run_command(input: &str) -> std::process::Output {
let mut stdout: Vec<u8> = Vec::new();
let mut stderr: Vec<u8> = Vec::new();
let args = m4::Args {
file: Some(input.into()),
files: Some(input.into()),
..m4::Args::default()
};
let result = m4::run(&mut stdout, &mut stderr, args);
Expand Down

0 comments on commit 233311d

Please sign in to comment.