#Clap Remove the 'tip' Messages

5 messages · Page 1 of 1 (latest)

kindred anchor
#

When I run my executable that I used clap for and pass an argument that is unknown, example name -c, I get this message

error: unexpected argument '-c' found

  tip: to pass '-c' as a value, use '-- -c'

Usage: todo [DIRECTORY]

For more information, try '--help'.

Which is good except for the tip message. I would like the error message to not print out the 'tip'. I am not sure If this is something to do with my configuration so I will leave that below.

I my clap command and argument are declared as:

    let mut command = Command::new("todo")
        .author(AUTHORS)
        .about(ABOUT.to_owned())
        .help_template(HELP.to_owned());

and a command declared as:

Arg::new("directory")
        .value_name("DIRECTORY")
        .help("Specify the search directory. If none provided, search the current directory.")
        .index(1)
slim mist
#

The tip is saying that if you literally want to pass -c as a directory name, then you need to pass -- -c

#

you have a DIRECTORY parameter right? So if someone wanted to use the directory -c then they'd need to pass -- -c

#

You can turn hints off in general by disabling the error-context feature

kindred anchor
#

Oh okay I see what it means now thank you