File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ extern crate clap;
2
+
3
+ use clap:: { App , AppSettings , SubCommand } ;
4
+
5
+ fn main ( ) {
6
+ // You can use AppSettings to change the application level behavior of clap. .setting() function
7
+ // of App struct takes AppSettings enum as argument. There is also .settings() function which
8
+ // takes slice of AppSettings enum. You can learn more about AppSettings in the documentation,
9
+ // which also has examples on each setting.
10
+ //
11
+ // This example will only show usage of one AppSettings setting. See documentation for more
12
+ // information.
13
+
14
+ let matches = App :: new ( "myapp" )
15
+ . setting ( AppSettings :: SubcommandsNegateReqs )
16
+ // Negates requirement of parent command.
17
+
18
+ . arg_from_usage ( "<input> 'input file to use'" )
19
+ // Required positional argument called input. This
20
+ // will be only required if subcommand is not present.
21
+
22
+ . subcommand ( SubCommand :: with_name ( "help" )
23
+ . about ( "shows help message" ) )
24
+ // if program is invoked with subcommand, you do not
25
+ // need to specify the <input> argument anymore due to
26
+ // the AppSettings::SubcommandsNegateReqs setting.
27
+
28
+ . get_matches ( ) ;
29
+
30
+ // Contiued program logic goes here...
31
+ }
You can’t perform that action at this time.
0 commit comments