AppSettings::ArgRequiredElseHelp
, Arg::default_value
- note however that these two are not compatible because the default value is considered to be present.
@CreepySkeleton Thanks for the explanation/link! This situation is indeed suboptimal, at least clap is typically used only by the final binary and not by many different intermediate libraries with different flags. The "binary only" features mentioned by withoutboats would be a perfect fit for this IMHO. I personally think that enabling App: Send
behind a feature is better than preventing the (probably rather uncommon) compilation failure if two crates with and without app-send
depend on clap and one crate uses a not-Send + Sync
validator{_os}
, but that is not for me to decide.
I was talking about the parking_lot
feature of tokio, but I initially forgot that in clap, one also has to adapt the bound on F
to also require Send + Sync
. If this was not the case, the situation would be analogous to tokio, as the change would be purely internal. This could be fixed by also requiring Send + Sync
for F
even when app-send
is disabled, as the public API does not depend on app-send
then (I updated #1771 to mention this).
tests/ui/subcommand_on_struct.rs
still returns the expected error but it also complains about not having ArgMatches in the scope, even if that I can see it is always used as ::clap::ArgMatches
in the derive code...
I'm trying to get App::new
from separate function, such as
let app = App::new(crate_name!()).version(crate_version!());
app.subcommand(put_cmd)
...
pub fn config_cmd() -> App{
return App::new...
}
This returns missing lifetime specifier
... does somebody knows the solution?
Hello there, I'm on the website and I wonder if some content cannot be load. Sections seem to be really empty, for example : https://clap.rs/?page_id=26 I only see :
clap can generate bash, fish, zsh and even PowerShell completion files at compile time!
frawk
with cargo
but I get this error: no method named
aboutfound for struct
clap::Argin the current scope
any idea about how to deal with it?
help
or something like that late in clap 3 beta series.
flattern
, otherwise it will not work):#[derive(Parser, Debug)]
struct Opt {
/// set the listen addr
#[clap(short = 'a', long = "addr", default_value = "127.0.0.1")]
addr: String,
/// set the listen port
#[clap(short = 'p', long = "port", default_value = "8080")]
port: u16,
#[clap(flatten)]
session_config: SessionConfig,
#[clap(flatten)]
db_config: DbConfig,
}