Help clap.rs multiple values and sub-command

Hello everyone,
Im developing a pet project to learn Rust, is another find clone.....

I want to be able to find files and directories in several paths, using several patterns to search for, at the same time. Then i want to be able to perform file operations over the results. This is the code snippet that configures clap.rs:

fn main() {
    let app = App::new("findx")
        .version(crate_version!())
        .author(crate_authors!())
        .about("find + directory operations utility")
        .setting(AppSettings::ArgRequiredElseHelp)
        .arg(
            Arg::with_name("paths")
                .short("p")
                .long("paths")
                .value_name("PATHS")
                .takes_value(true)
                .multiple(true)
                .help("Directories to search for the PATTERNS"),
        )
        .arg(
            Arg::with_name("patterns")
                .short("t")
                .long("patterns")
                .value_name("PATTERNS")
                .required(true)
                .takes_value(true)
                .multiple(true)
                .help("Patterns to search for"),
        )
        .subcommand(
            SubCommand::with_name("rename")
                .about("Rename the last part element of the path")
                .arg(
                    Arg::with_name("string")
                        .value_name("STRING")
                        .takes_value(true)
                        .required(true)
                        .help("Append the STRING to the end of every dir/file founded"),
                ),
        );

This is one of the execution of the program:

➜  findx git:(master) ✗ ./target/debug/findx -p ../ -t findx rename findit
paths:    ["../"]
patterns: ["findx", "rename", "findit"]
Operation:None

as you can see is taking the subcommand and the argument of the subcommand as values of -t.

this is with the -- "thing" between the main program and the subcommand

 findx git:(master) ✗ ./target/debug/findx -p ../ -t findx -- rename findit
error: The subcommand 'rename' wasn't recognized
        Did you mean 'rename'?

If you believe you received this message in error, try re-running with 'findx -- rename'

USAGE:
    findx --paths <PATHS>... --patterns <PATTERNS>...

For more information try --help

and of course that i mean rename, could someone help me with this or even at least tell me if is possible to do this with clap.rs.

Thanks in advance.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.