@@ -145,19 +145,19 @@ pub struct Opt {
145
145
pub aliases : Vec < Opt > ,
146
146
}
147
147
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
149
149
/// their shared description and properties.
150
150
#[ deriving( Clone , PartialEq , Eq ) ]
151
151
pub struct OptGroup {
152
- /// Short Name of the `OptGroup`
152
+ /// Short name of the option, e.g. `h` for a `-h` option
153
153
pub short_name : String ,
154
- /// Long Name of the `OptGroup`
154
+ /// Long name of the option, e.g. `help` for a `--help` option
155
155
pub long_name : String ,
156
- /// Hint
156
+ /// Hint for argument, e.g. `FILE` for a `-o FILE` option
157
157
pub hint : String ,
158
- /// Description
158
+ /// Description for usage help text
159
159
pub desc : String ,
160
- /// Whether it has an argument
160
+ /// Whether option has an argument
161
161
pub hasarg : HasArg ,
162
162
/// How often it can occur
163
163
pub occur : Occur
@@ -393,6 +393,12 @@ fn find_opt(opts: &[Opt], nm: Name) -> Option<uint> {
393
393
}
394
394
395
395
/// 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
396
402
pub fn reqopt ( short_name : & str , long_name : & str , desc : & str , hint : & str ) -> OptGroup {
397
403
let len = short_name. len ( ) ;
398
404
assert ! ( len == 1 || len == 0 ) ;
@@ -407,6 +413,12 @@ pub fn reqopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptG
407
413
}
408
414
409
415
/// 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
410
422
pub fn optopt ( short_name : & str , long_name : & str , desc : & str , hint : & str ) -> OptGroup {
411
423
let len = short_name. len ( ) ;
412
424
assert ! ( len == 1 || len == 0 ) ;
@@ -421,6 +433,10 @@ pub fn optopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptG
421
433
}
422
434
423
435
/// 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
424
440
pub fn optflag ( short_name : & str , long_name : & str , desc : & str ) -> OptGroup {
425
441
let len = short_name. len ( ) ;
426
442
assert ! ( len == 1 || len == 0 ) ;
@@ -436,6 +452,10 @@ pub fn optflag(short_name: &str, long_name: &str, desc: &str) -> OptGroup {
436
452
437
453
/// Create a long option that can occur more than once and does not
438
454
/// 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
439
459
pub fn optflagmulti ( short_name : & str , long_name : & str , desc : & str ) -> OptGroup {
440
460
let len = short_name. len ( ) ;
441
461
assert ! ( len == 1 || len == 0 ) ;
@@ -450,6 +470,12 @@ pub fn optflagmulti(short_name: &str, long_name: &str, desc: &str) -> OptGroup {
450
470
}
451
471
452
472
/// 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
453
479
pub fn optflagopt ( short_name : & str , long_name : & str , desc : & str , hint : & str ) -> OptGroup {
454
480
let len = short_name. len ( ) ;
455
481
assert ! ( len == 1 || len == 0 ) ;
@@ -465,6 +491,12 @@ pub fn optflagopt(short_name: &str, long_name: &str, desc: &str, hint: &str) ->
465
491
466
492
/// Create a long option that is optional, takes an argument, and may occur
467
493
/// 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
468
500
pub fn optmulti ( short_name : & str , long_name : & str , desc : & str , hint : & str ) -> OptGroup {
469
501
let len = short_name. len ( ) ;
470
502
assert ! ( len == 1 || len == 0 ) ;
0 commit comments