Skip to content

Commit a8fdcc3

Browse files
committed
rollup merge of rust-lang#18531 : robinst/getopts-doc
2 parents bb7805f + 41a8a15 commit a8fdcc3

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

src/libgetopts/lib.rs

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,19 @@ pub struct Opt {
145145
pub aliases: Vec<Opt>,
146146
}
147147

148-
/// One group of options, e.g., both -h and --help, along with
148+
/// One group of options, e.g., both `-h` and `--help`, along with
149149
/// their shared description and properties.
150150
#[deriving(Clone, PartialEq, Eq)]
151151
pub struct OptGroup {
152-
/// Short Name of the `OptGroup`
152+
/// Short name of the option, e.g. `h` for a `-h` option
153153
pub short_name: String,
154-
/// Long Name of the `OptGroup`
154+
/// Long name of the option, e.g. `help` for a `--help` option
155155
pub long_name: String,
156-
/// Hint
156+
/// Hint for argument, e.g. `FILE` for a `-o FILE` option
157157
pub hint: String,
158-
/// Description
158+
/// Description for usage help text
159159
pub desc: String,
160-
/// Whether it has an argument
160+
/// Whether option has an argument
161161
pub hasarg: HasArg,
162162
/// How often it can occur
163163
pub occur: Occur
@@ -393,6 +393,12 @@ fn find_opt(opts: &[Opt], nm: Name) -> Option<uint> {
393393
}
394394

395395
/// Create a long option that is required and takes an argument.
396+
///
397+
/// * `short_name` - e.g. `"h"` for a `-h` option, or `""` for none
398+
/// * `long_name` - e.g. `"help"` for a `--help` option, or `""` for none
399+
/// * `desc` - Description for usage help
400+
/// * `hint` - Hint that is used in place of the argument in the usage help,
401+
/// e.g. `"FILE"` for a `-o FILE` option
396402
pub fn reqopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup {
397403
let len = short_name.len();
398404
assert!(len == 1 || len == 0);
@@ -407,6 +413,12 @@ pub fn reqopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptG
407413
}
408414

409415
/// Create a long option that is optional and takes an argument.
416+
///
417+
/// * `short_name` - e.g. `"h"` for a `-h` option, or `""` for none
418+
/// * `long_name` - e.g. `"help"` for a `--help` option, or `""` for none
419+
/// * `desc` - Description for usage help
420+
/// * `hint` - Hint that is used in place of the argument in the usage help,
421+
/// e.g. `"FILE"` for a `-o FILE` option
410422
pub fn optopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup {
411423
let len = short_name.len();
412424
assert!(len == 1 || len == 0);
@@ -421,6 +433,10 @@ pub fn optopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptG
421433
}
422434

423435
/// Create a long option that is optional and does not take an argument.
436+
///
437+
/// * `short_name` - e.g. `"h"` for a `-h` option, or `""` for none
438+
/// * `long_name` - e.g. `"help"` for a `--help` option, or `""` for none
439+
/// * `desc` - Description for usage help
424440
pub fn optflag(short_name: &str, long_name: &str, desc: &str) -> OptGroup {
425441
let len = short_name.len();
426442
assert!(len == 1 || len == 0);
@@ -436,6 +452,10 @@ pub fn optflag(short_name: &str, long_name: &str, desc: &str) -> OptGroup {
436452

437453
/// Create a long option that can occur more than once and does not
438454
/// take an argument.
455+
///
456+
/// * `short_name` - e.g. `"h"` for a `-h` option, or `""` for none
457+
/// * `long_name` - e.g. `"help"` for a `--help` option, or `""` for none
458+
/// * `desc` - Description for usage help
439459
pub fn optflagmulti(short_name: &str, long_name: &str, desc: &str) -> OptGroup {
440460
let len = short_name.len();
441461
assert!(len == 1 || len == 0);
@@ -450,6 +470,12 @@ pub fn optflagmulti(short_name: &str, long_name: &str, desc: &str) -> OptGroup {
450470
}
451471

452472
/// Create a long option that is optional and takes an optional argument.
473+
///
474+
/// * `short_name` - e.g. `"h"` for a `-h` option, or `""` for none
475+
/// * `long_name` - e.g. `"help"` for a `--help` option, or `""` for none
476+
/// * `desc` - Description for usage help
477+
/// * `hint` - Hint that is used in place of the argument in the usage help,
478+
/// e.g. `"FILE"` for a `-o FILE` option
453479
pub fn optflagopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup {
454480
let len = short_name.len();
455481
assert!(len == 1 || len == 0);
@@ -465,6 +491,12 @@ pub fn optflagopt(short_name: &str, long_name: &str, desc: &str, hint: &str) ->
465491

466492
/// Create a long option that is optional, takes an argument, and may occur
467493
/// multiple times.
494+
///
495+
/// * `short_name` - e.g. `"h"` for a `-h` option, or `""` for none
496+
/// * `long_name` - e.g. `"help"` for a `--help` option, or `""` for none
497+
/// * `desc` - Description for usage help
498+
/// * `hint` - Hint that is used in place of the argument in the usage help,
499+
/// e.g. `"FILE"` for a `-o FILE` option
468500
pub fn optmulti(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup {
469501
let len = short_name.len();
470502
assert!(len == 1 || len == 0);

0 commit comments

Comments
 (0)