• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
2 //
3 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6 // option. This file may not be copied, modified, or distributed
7 // except according to those terms.
8 
9 // This should be in tests but it will not work until
10 // https://github.com/rust-lang/rust/issues/24584 is fixed
11 
12 //! A test to check that structopt compiles with deny(missing_docs)
13 //!
14 //! Running this example with --help prints this message:
15 //! -----------------------------------------------------
16 //! structopt 0.3.25
17 //! Some subcommands
18 //!
19 //! USAGE:
20 //!     deny_missing_docs [FLAGS] [SUBCOMMAND]
21 //!
22 //! FLAGS:
23 //!     -h, --help       Prints help information
24 //!     -V, --version    Prints version information
25 //!     -v
26 //!
27 //! SUBCOMMANDS:
28 //!     a       command A
29 //!     b       command B
30 //!     c       command C
31 //!     help    Prints this message or the help of the given subcommand(s)
32 //! -----------------------------------------------------
33 
34 #![deny(missing_docs)]
35 
36 use structopt::StructOpt;
37 
38 /// The options
39 #[derive(StructOpt, Debug, PartialEq)]
40 pub struct Opt {
41     #[structopt(short)]
42     verbose: bool,
43     #[structopt(subcommand)]
44     cmd: Option<Cmd>,
45 }
46 
47 /// Some subcommands
48 #[derive(StructOpt, Debug, PartialEq)]
49 pub enum Cmd {
50     /// command A
51     A,
52     /// command B
53     B {
54         /// Alice?
55         #[structopt(short)]
56         alice: bool,
57     },
58     /// command C
59     C(COpt),
60 }
61 
62 /// The options for C
63 #[derive(StructOpt, Debug, PartialEq)]
64 pub struct COpt {
65     #[structopt(short)]
66     bob: bool,
67 }
68 
main()69 fn main() {
70     println!("{:?}", Opt::from_args());
71 }
72