11use clap:: { App , Arg } ;
22
33pub struct Config {
4- pub minimize : bool ,
4+ pub minimize : bool ,
55 pub separator : String ,
6- pub file : Option < String > ,
7- pub outfile : Option < String > ,
6+ pub file : Option < String > ,
7+ pub out : Option < String > ,
88}
99
1010impl Config {
@@ -13,36 +13,17 @@ impl Config {
1313 . version ( "1.0.2" )
1414 . author ( "Axel Lindeberg" )
1515 . about ( "Makes creating tables in markdown much easier!" )
16- . arg ( Arg :: with_name ( "minimize" )
17- . help ( "Minimizes table output" )
18- . long ( "minimize" )
19- . short ( "m" )
20- )
21- . arg ( Arg :: with_name ( "file" )
22- . help ( "Reads table values from this if given, stdin otherwise." )
23- . long ( "file" )
24- . short ( "f" )
25- . takes_value ( true )
26- )
27- . arg ( Arg :: with_name ( "outfile" )
28- . help ( "Prints output to this if given, stdout otherwise." )
29- . long ( "out" )
30- . short ( "o" )
31- . takes_value ( true )
32- )
33- . arg ( Arg :: with_name ( "separator" )
34- . help ( "String that separates values." )
35- . long ( "separator" )
36- . short ( "s" )
37- . default_value ( "," )
38- )
16+ . arg ( Arg :: from_usage ( "[FILE] 'Reads table tables from this. [default: stdin]'" ) )
17+ . arg ( Arg :: from_usage ( "-o --out [FILE] 'Prints output to this. [default: stdout]'" ) )
18+ . arg ( Arg :: from_usage ( "-s --separator [STRING] 'Separates values. [default: ,]'" ) )
19+ . arg ( Arg :: from_usage ( "-m --minimize 'Minimizes table output'" ) )
3920 . get_matches ( ) ;
4021
4122 Config {
4223 minimize : args. is_present ( "minimize" ) ,
43- separator : args. value_of ( "separator" ) . map ( String :: from ) . unwrap ( ) ,
44- file : args. value_of ( "file " ) . map ( String :: from) ,
45- outfile : args. value_of ( "outfile " ) . map ( String :: from) ,
24+ separator : args. value_of ( "separator" ) . unwrap_or ( "," ) . to_string ( ) ,
25+ file : args. value_of ( "FILE " ) . map ( String :: from) ,
26+ out : args. value_of ( "out " ) . map ( String :: from) ,
4627 }
4728 }
4829}
0 commit comments