File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 11use std:: error:: Error ;
22use structopt:: StructOpt ;
33
4+ /// Parse a single key-value pair
45fn parse_key_val < T , U > ( s : & str ) -> Result < ( T , U ) , Box < dyn Error > >
56where
67 T : std:: str:: FromStr ,
1617
1718#[ derive( StructOpt , Debug ) ]
1819struct Opt {
19- #[ structopt( short = "D" , parse( try_from_str = parse_key_val) ) ]
20+ // number_of_values = 1 forces the user to repeat the -D option for each key-value pair:
21+ // my_program -D a=1 -D b=2
22+ // Without number_of_values = 1 you can do:
23+ // my_program -D a=1 b=2
24+ // but this makes adding an argument after the values impossible:
25+ // my_program -D a=1 -D b=2 my_input_file
26+ // becomes invalid.
27+ #[ structopt( short = "D" , parse( try_from_str = parse_key_val) , number_of_values = 1 ) ]
2028 defines : Vec < ( String , i32 ) > ,
2129}
2230
You can’t perform that action at this time.
0 commit comments