|
435 | 435 | //! /// for its type (in this case 0).
|
436 | 436 | //! #[structopt(skip)]
|
437 | 437 | //! skipped: u32,
|
438 |
| -//! |
439 | 438 | //! }
|
440 | 439 | //!
|
441 | 440 | //! # Opt::from_iter(
|
|
452 | 451 | //! #[derive(StructOpt)]
|
453 | 452 | //! struct Opt {
|
454 | 453 | //! #[structopt(default_value = "", long)]
|
455 |
| -//! prefix: String |
| 454 | +//! prefix: String, |
456 | 455 | //! }
|
457 | 456 | //! ```
|
458 | 457 | //!
|
|
474 | 473 | //! struct Opt {
|
475 | 474 | //! // just leave the `= "..."` part and structopt will figure it for you
|
476 | 475 | //! #[structopt(default_value, long)]
|
477 |
| -//! prefix: String // `String` implements both `Default` and `ToString` |
| 476 | +//! prefix: String, // `String` implements both `Default` and `ToString` |
478 | 477 | //! }
|
479 | 478 | //! ```
|
480 | 479 | //!
|
|
499 | 498 | //! #[derive(StructOpt)]
|
500 | 499 | //! #[structopt(about = "I am a program and I work, just pass `-h`")]
|
501 | 500 | //! struct Foo {
|
502 |
| -//! #[structopt(short, help = "Pass `-h` and you'll see me!")] |
503 |
| -//! bar: String |
| 501 | +//! #[structopt(short, help = "Pass `-h` and you'll see me!")] |
| 502 | +//! bar: String, |
504 | 503 | //! }
|
505 | 504 | //! ```
|
506 | 505 | //!
|
|
513 | 512 | //! #[derive(StructOpt)]
|
514 | 513 | //! /// I am a program and I work, just pass `-h`
|
515 | 514 | //! struct Foo {
|
516 |
| -//! /// Pass `-h` and you'll see me! |
517 |
| -//! bar: String |
| 515 | +//! /// Pass `-h` and you'll see me! |
| 516 | +//! bar: String, |
518 | 517 | //! }
|
519 | 518 | //! ```
|
520 | 519 | //!
|
|
555 | 554 | //! /// until I'll have destroyed humanity. Enjoy your
|
556 | 555 | //! /// pathetic existence, you mere mortals.
|
557 | 556 | //! #[structopt(long)]
|
558 |
| -//! kill_all_humans: bool |
| 557 | +//! kill_all_humans: bool, |
559 | 558 | //! }
|
560 | 559 | //! ```
|
561 | 560 | //!
|
|
665 | 664 | //!
|
666 | 665 | //! #[derive(StructOpt)]
|
667 | 666 | //! struct Foo {
|
668 |
| -//! #[structopt(short, long, env = "PARAMETER_VALUE")] |
669 |
| -//! parameter_value: String |
| 667 | +//! #[structopt(short, long, env = "PARAMETER_VALUE")] |
| 668 | +//! parameter_value: String, |
670 | 669 | //! }
|
671 | 670 | //! ```
|
672 | 671 | //!
|
|
688 | 687 | //!
|
689 | 688 | //! #[derive(StructOpt)]
|
690 | 689 | //! struct Foo {
|
691 |
| -//! #[structopt(long = "secret", env = "SECRET_VALUE", hide_env_values = true)] |
692 |
| -//! secret_value: String |
| 690 | +//! #[structopt(long = "secret", env = "SECRET_VALUE", hide_env_values = true)] |
| 691 | +//! secret_value: String, |
693 | 692 | //! }
|
694 | 693 | //! ```
|
695 | 694 | //!
|
|
707 | 706 | //!
|
708 | 707 | //! #[derive(StructOpt)]
|
709 | 708 | //! struct Foo {
|
710 |
| -//! #[structopt(long = "secret", env)] |
711 |
| -//! secret_value: String |
| 709 | +//! #[structopt(long = "secret", env)] |
| 710 | +//! secret_value: String, |
712 | 711 | //! }
|
713 | 712 | //! ```
|
714 | 713 | //!
|
|
774 | 773 | //! #[structopt(short)]
|
775 | 774 | //! patch: bool,
|
776 | 775 | //! #[structopt(parse(from_os_str))]
|
777 |
| -//! files: Vec<PathBuf> |
| 776 | +//! files: Vec<PathBuf>, |
778 | 777 | //! },
|
779 | 778 | //! Fetch {
|
780 | 779 | //! #[structopt(long)]
|
781 | 780 | //! dry_run: bool,
|
782 | 781 | //! #[structopt(long)]
|
783 | 782 | //! all: bool,
|
784 |
| -//! repository: Option<String> |
| 783 | +//! repository: Option<String>, |
785 | 784 | //! },
|
786 | 785 | //! Commit {
|
787 | 786 | //! #[structopt(short)]
|
788 | 787 | //! message: Option<String>,
|
789 | 788 | //! #[structopt(short)]
|
790 |
| -//! all: bool |
791 |
| -//! } |
| 789 | +//! all: bool, |
| 790 | +//! }, |
792 | 791 | //! }
|
793 | 792 | //! ```
|
794 | 793 | //!
|
|
807 | 806 | //! supervising_faerie: String,
|
808 | 807 | //! /// The faerie tree this cookie is being made in.
|
809 | 808 | //! tree: Option<String>,
|
810 |
| -//! #[structopt(subcommand)] // Note that we mark a field as a subcommand |
811 |
| -//! cmd: Command |
| 809 | +//! #[structopt(subcommand)] // Note that we mark a field as a subcommand |
| 810 | +//! cmd: Command, |
812 | 811 | //! }
|
813 | 812 | //!
|
814 | 813 | //! #[derive(StructOpt)]
|
815 | 814 | //! enum Command {
|
816 | 815 | //! /// Pound acorns into flour for cookie dough.
|
817 | 816 | //! Pound {
|
818 |
| -//! acorns: u32 |
| 817 | +//! acorns: u32, |
819 | 818 | //! },
|
820 | 819 | //! /// Add magical sparkles -- the secret ingredient!
|
821 | 820 | //! Sparkle {
|
822 | 821 | //! #[structopt(short, parse(from_occurrences))]
|
823 | 822 | //! magicality: u64,
|
824 | 823 | //! #[structopt(short)]
|
825 |
| -//! color: String |
| 824 | +//! color: String, |
826 | 825 | //! },
|
827 | 826 | //! Finish(Finish),
|
828 | 827 | //! }
|
|
832 | 831 | //! struct Finish {
|
833 | 832 | //! #[structopt(short)]
|
834 | 833 | //! time: u32,
|
835 |
| -//! #[structopt(subcommand)] // Note that we mark a field as a subcommand |
836 |
| -//! finish_type: FinishType |
| 834 | +//! #[structopt(subcommand)] // Note that we mark a field as a subcommand |
| 835 | +//! finish_type: FinishType, |
837 | 836 | //! }
|
838 | 837 | //!
|
839 | 838 | //! // subsubcommand!
|
840 | 839 | //! #[derive(StructOpt)]
|
841 | 840 | //! enum FinishType {
|
842 | 841 | //! Glaze {
|
843 |
| -//! applications: u32 |
| 842 | +//! applications: u32, |
844 | 843 | //! },
|
845 | 844 | //! Powder {
|
846 | 845 | //! flavor: String,
|
847 |
| -//! dips: u32 |
| 846 | +//! dips: u32, |
848 | 847 | //! }
|
849 | 848 | //! }
|
850 | 849 | //! ```
|
|
868 | 867 | //! struct Foo {
|
869 | 868 | //! file: String,
|
870 | 869 | //! #[structopt(subcommand)]
|
871 |
| -//! cmd: Option<Command> |
| 870 | +//! cmd: Option<Command>, |
872 | 871 | //! }
|
873 | 872 | //!
|
874 | 873 | //! #[derive(StructOpt)]
|
875 | 874 | //! enum Command {
|
876 | 875 | //! Bar,
|
877 | 876 | //! Baz,
|
878 |
| -//! Quux |
| 877 | +//! Quux, |
879 | 878 | //! }
|
880 | 879 | //! ```
|
881 | 880 | //!
|
|
953 | 952 | //! BaseCli(BaseCli),
|
954 | 953 | //! Dex {
|
955 | 954 | //! arg2: i32,
|
956 |
| -//! } |
| 955 | +//! }, |
957 | 956 | //! }
|
958 | 957 | //! ```
|
959 | 958 | //!
|
|
1068 | 1067 | //!
|
1069 | 1068 | //! // a struct with single custom argument
|
1070 | 1069 | //! #[derive(StructOpt)]
|
1071 |
| -//! struct GenericArgs<T:FromStr> where <T as FromStr>::Err: fmt::Display + fmt::Debug { |
| 1070 | +//! struct GenericArgs<T: FromStr> where <T as FromStr>::Err: fmt::Display + fmt::Debug { |
1072 | 1071 | //! generic_arg_1: String,
|
1073 | 1072 | //! generic_arg_2: String,
|
1074 |
| -//! custom_arg_1: T |
| 1073 | +//! custom_arg_1: T, |
1075 | 1074 | //! }
|
1076 | 1075 | //! ```
|
1077 | 1076 | //!
|
|
1081 | 1080 | //! # use structopt::StructOpt;
|
1082 | 1081 | //! // a struct with multiple custom arguments in a substructure
|
1083 | 1082 | //! #[derive(StructOpt)]
|
1084 |
| -//! struct GenericArgs<T:StructOpt> { |
| 1083 | +//! struct GenericArgs<T: StructOpt> { |
1085 | 1084 | //! generic_arg_1: String,
|
1086 | 1085 | //! generic_arg_2: String,
|
1087 | 1086 | //! #[structopt(flatten)]
|
1088 |
| -//! custom_args: T |
| 1087 | +//! custom_args: T, |
1089 | 1088 | //! }
|
1090 | 1089 | //! ```
|
1091 | 1090 |
|
|
0 commit comments