You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rt file - change to handle many files and pattern match #2
handle many files, both with regex matching > 1 and user supplying > 1 string
match on closest test file to given pattern
in the ruby library that's the predecessor to this https://github.com/sckott/rubrbrb 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 useful
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 rt file probably with a new flag like rt file -r someregex - and then run all of those test files that match
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 testthatstructTestThatFile{/// 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!(),}}
Activity
sckott commentedon Jan 11, 2025
@JosiahParry Trying to figure out how to modify the
rt filesubcommand https://github.com/sckott/rt-cli/blob/main/rt-cli/src/main.rs#L79 - to do a regex on the user input to the subcommand, but I'm not sure the best way to approach it.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
rt fileprobably with a new flag likert file -r someregex- and then run all of those test files that matchOr 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?
JosiahParry commentedon Jan 11, 2025
I think you could add another argument to the struct like so:
Then the CLI can be modified to match on both of the arguments:
sckott commentedon Jan 16, 2025
@JosiahParry Thank you!