Skip to content

Commit 7d67867

Browse files
committed
Make Rails arguments optional
Calling rails-new without any arguments fails with error: (error: the following required arguments were not provided: <ARGS>..). Making rails arguments optional allows to simply run rails-new and see what params are required for scaffolding new rails application (for example app name).
1 parent aad1b66 commit 7d67867

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/rails_new.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clap::{Parser, Subcommand};
33
#[derive(Parser)]
44
#[command(version, about, long_about = None, subcommand_negates_reqs = true)]
55
pub struct Cli {
6-
#[clap(trailing_var_arg = true, required = true)]
6+
#[clap(trailing_var_arg = true)]
77
/// arguments passed to `rails new`
88
pub args: Vec<String>,
99
#[clap(long, short = 'u', default_value = "latest")]

tests/cli.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
use assert_cmd::prelude::*;
2-
use predicates::prelude::*;
32
use std::process::Command;
43

54
#[test]
65
fn requires_a_name() -> Result<(), Box<dyn std::error::Error>> {
7-
let mut cmd = Command::cargo_bin("rails-new")?;
6+
let mut cmd = Command::cargo_bin("rails-new")?;
87

9-
cmd.assert()
10-
.failure()
11-
.stderr(predicate::str::contains(
12-
"the following required arguments were not provided:",
13-
))
14-
.stderr(predicate::str::contains("<ARGS>..."));
8+
cmd
9+
.spawn()
10+
.unwrap()
11+
.wait_with_output()
12+
.expect("rails new weblog --api");
1513

16-
Ok(())
17-
}
14+
Ok(())
15+
}

0 commit comments

Comments
 (0)