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

Fix up some docs about argument renaming. #148

Merged
merged 1 commit into from
Nov 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/rename_all.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Example on how the `rename_all` parameter works.
//!
//! `rename_all` can be used to override the casing style used during argument
//! generation. Default the `verbatim-case` style will be used but there is a wide
//! generation. By default the `verbatim-case` style will be used but there are a wide
//! variety of other styles available.
//!
//! ## Supported styles overview:
Expand Down Expand Up @@ -41,7 +41,7 @@ enum Opt {
#[structopt(rename_all = "pascal_case")]
SecondCommand {
// We can also override it again on a single field.
/// Nice quite flag. No one is annoyed.
/// Nice quiet flag. No one is annoyed.
#[structopt(rename_all = "snake_case", long)]
bar_option: bool,

Expand Down
23 changes: 15 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,19 @@
//! (sub-)command:
//!
//! - short (e.g. `-h`),
//! - long (e.g. `--help`)
//! - long (e.g. `--help`)
//! - and positional.
//!
//! Like clap, structopt defaults to creation positional arguments.
//! Like clap, structopt defaults to creating positional arguments.
//!
//! If you want to generate a long argument you can either specify `long`
//! to get a long flag generated by converting the field name to
//! `kebab-case` or `long = $NAME`. For short arguments `short` will use
//! the first letter of the field name but equivalent to the long option
//! its also possible to use a custom letter through `short = $LETTER`.
//! If you want to generate a long argument you can specify either
//! `long = $NAME`, or just `long` to get a long flag generated using
//! the field name. The generated casing style can be modified using
//! the `rename_all` attribute. See the `rename_all` example for more.
//!
//! For short arguments, `short` will use the first letter of the
//! field name by default, but just like the long option it's also
//! possible to use a custom letter through `short = $LETTER`.
//!
//! If an argument is renamed using `name = $NAME` any following call to
//! `short` or `long` will use the new name.
Expand All @@ -162,6 +165,7 @@
//! use structopt::StructOpt;
//!
//! #[derive(StructOpt)]
//! #[structopt(rename_all = "kebab-case")]
//! struct Opt {
//! /// This option can be specified with something like `--foo-option
//! /// value` or `--foo-option=value`
Expand All @@ -187,7 +191,10 @@
//! my_positional: String,
//! }
//!
//! # fn main() {}
//! # fn main() {
//! # Opt::from_clap(&Opt::clap().get_matches_from(
//! # &["test", "--foo-option", "", "-b", "", "--baz", "", "--custom", "", "positional"]));
//! # }
//! ```
//!
//! ## Help messages
Expand Down