Skip to content
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

use uutils-args or clap for argument management #113

Open
sylvestre opened this issue Sep 7, 2021 · 4 comments
Open

use uutils-args or clap for argument management #113

sylvestre opened this issue Sep 7, 2021 · 4 comments

Comments

@sylvestre
Copy link
Sponsor Contributor

findutils is doing way too many argument management by hand.
It should be delegate to clap
for example

while i < args.len()
&& (args[i] == "-" || !args[i].starts_with('-'))
&& args[i] != "!"
&& args[i] != "("

findutils/src/find/mod.rs

Lines 167 to 175 in ac576f5

fn print_help() {
println!(
r"Usage: find [path...] [expression]
If no path is supplied then the current working directory is used by default.
Early alpha implementation. Currently the only expressions supported are
-print
-name case-sensitive_filename_pattern

findutils/src/find/mod.rs

Lines 205 to 207 in ac576f5

fn print_version() {
println!("find (Rust) {}", env!("CARGO_PKG_VERSION"));
}

let mut invert_next_matcher = false;
while i < args.len() {
let possible_submatcher = match args[i] {
"-print" => Some(printer::Printer::new_box()),
"-true" => Some(logical_matchers::TrueMatcher::new_box()),
"-false" => Some(logical_matchers::FalseMatcher::new_box()),
"-name" => {
if i >= args.len() - 1 {

@mcharsley
Copy link
Contributor

mcharsley commented Sep 8, 2021 via email

@sylvestre
Copy link
Sponsor Contributor Author

Yeah, indeed, not a trivial task for sure!
I think we can delegate the easy stuff to clap and parse the complex stuff by hand

@sylvestre
Copy link
Sponsor Contributor Author

@sylvestre sylvestre changed the title use clap for argument management use uutils-args or clap for argument management Feb 11, 2024
@tertsdiepraam
Copy link
Member

tertsdiepraam commented Feb 11, 2024

Uutils-args can't do this at the moment, I think, but we can probably extend it somehow to do it. Actually, the whole syntax tree might be difficult to implement. I'll have to look into it. It reminds me of the parsing I implemented for env

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants