These are chat archives for kbknapp/clap-rs

7th
Mar 2018
Nirudium
@NoorMkdad
Mar 07 2018 03:38
@tanriol Pretty much
What you said as the reason to me wanting the single hyphen longs
Sean Leffler
@sdleffler
Mar 07 2018 07:31
Hey folks! Is it possible to require that either a subcommand is supplied, or arguments are supplied to a command? I suppose what I really want is a "default subcommand", such that if no subcommand is parsed, we instead attempt to parse the original command as the subcommand.
Suppose I have a command foo, with subcommands bar and baz. I want foo bar ... and foo baz ... to call bar and baz; but I want foo ... to act as if, say, foo bar ... were called.
William Murphy
@willmurphyscode
Mar 07 2018 12:09

@kbknapp for "Change default help template (ARGS should be first in the sections but last in usage)" on kbknapp/clap-rs#1037, do you want ARGS to print even before USAGE in the help output, or immediately after USAGE? I'm assuming immediately after USAGE, like

clap-test v1.4.8

USAGE:
    clap-test [arg1] [arg2] [arg3]

ARGS:
    <arg1>    some
    <arg2>    some
    <arg3>    some

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

NOT like

clap-test v1.4.8

ARGS:
    <arg1>    some
    <arg2>    some
    <arg3>    some

USAGE:
    clap-test [arg1] [arg2] [arg3]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

I think I'm right (that we want the first output) but I wanted to double-check before I changed a bunch of string literals in all these tests.

Kevin K.
@kbknapp
Mar 07 2018 15:25
@sdleffler we don't have default subcommands, however there may be a issue open for it
because it's come up before
you can get close to what you want by using AppSettings::ArgRequiredElseHelp which will display the help message if neither a subcommand or arg is present
you could also use other things like SubcommandsNegateReqs and have a required arg (so either that arg must be present or a subcommand must be present)
@willmurphyscode after the usage
My comment about "still last in usage" is for the usage strings themselves, the ARGS should be the last thing displayed
Your first example is perfect :)
Joel Scarfone
@JoelScarfone
Mar 07 2018 19:54
I want to include a feature in my program on compile time, however clap seems to be taking over. For example, without clap i can run cargo run -- --features tokio-proto, however with clap, features is not recognized. Can i tell clap to ignore this somehow? I get error: Found argument '--features' which wasn't expected, or isn't valid in this context
Kevin K.
@kbknapp
Mar 07 2018 20:33
--features tokio-proto after the --isn't a compile time feature, it's a command line flag
if it was before the -- it's treated as a compile time feature in which case clap doens't even see it
so cargo run --features tokio-proto -- [args] [to] [clap]
Joel Scarfone
@JoelScarfone
Mar 07 2018 20:35
yeah i got it D:
thanks!
Kevin K.
@kbknapp
Mar 07 2018 20:35
no prob :)