-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rt file
- change to handle many files and pattern match
#2
Comments
@JosiahParry Trying to figure out how to modify the One thought I had was to call the list subcommand from within the file subcommand, but I'm not sure if that's a bad idea or not. Idea is to find all the matches in the list of test files that match the user input to Or we could factor out the code in the list subcommand https://github.com/sckott/rt-cli/blob/main/rt-cli/src/main.rs#L117-L153 and then be able to call that function Thoughts? |
I think you could add another argument to the struct like so: #[derive(PartialEq, Clone, Debug, FromArgs)]
#[argh(subcommand, name = "file")]
/// Test a single file using testthat
struct TestThatFile {
/// path to a test file
#[argh(option, short = 'f', long = "file")]
file: Option<String>,
/// regex pattern to match test files
#[argh(option, short = 'r', long = "regex")]
regex: Option<String>,
/// path to the package (default `.`)
#[argh(option, short = 'P', default = r#"".".to_string()"#)]
pkg_dir: String,
/// do not load the development package
#[argh(switch, short = 's')]
standalone: bool,
} Then the CLI can be modified to match on both of the arguments: Subcommands::File(cmd) => {
match (cmd.file, cmd.regex) {
(None, None) => todo!(), // error here
// use glob or something to find files that match the pattern
// then you can use run_rscript() over them
(None, Some(_)) => todo!(),
// keep default behavior here
(Some(_), None) => todo!(),
// maybe error here or run a single file and both ?
(Some(_), Some(_)) => todo!(),
}
} |
@JosiahParry Thank you! |
in the ruby library that's the predecessor to this https://github.com/sckott/rubrb
rb test
could handle the full file path or just a string and then match to the list of test files found - & handle more than 1 - it'd be nice to replicate this behavior as I've found it very usefulThe text was updated successfully, but these errors were encountered: