11use std:: path:: Path ;
22
33use anyhow:: Result ;
4- use clap:: { Arg , ArgAction , Command } ;
4+ use clap:: Parser ;
55use log:: { debug, info, warn, LevelFilter } ;
66use rusqlite:: Connection ;
77use walkdir:: WalkDir ;
@@ -10,31 +10,33 @@ mod sql;
1010mod tag;
1111mod tag_key;
1212
13- fn main ( ) -> Result < ( ) > {
14- let matches = Command :: new ( "musql" )
15- . arg (
16- Arg :: new ( "base-path" )
17- . required ( true )
18- . action ( ArgAction :: Set )
19- . help ( "File path to scan. If a directory is specified, all contents will be scanned recursively." ) ,
20- )
21- . arg (
22- Arg :: new ( "database-path" )
23- . long ( "database-path" )
24- . short ( 'o' )
25- . required ( false )
26- . default_value ( "./musql.db3" )
27- . action ( ArgAction :: Set )
28- . help ( "Path for the SQLite database that will be written to. It will be created if it does not exist." ) ,
29- )
30- . get_matches ( ) ;
13+ #[ derive( Parser , Debug ) ]
14+ #[ command( version, about, long_about = None ) ]
15+ struct Args {
16+ /// Name of the person to greet
17+ #[ arg(
18+ required = true ,
19+ help = "File path to scan. If a directory is specified, all contents will be scanned recursively."
20+ ) ]
21+ base_path : String ,
22+
23+ /// Number of times to greet
24+ #[ arg(
25+ short = 'o' ,
26+ long,
27+ required = false ,
28+ default_value = "./musql.db3" ,
29+ help = "Path for the SQLite database that will be written to. It will be created if it does not exist."
30+ ) ]
31+ database_path : String ,
32+ }
3133
34+ fn main ( ) -> Result < ( ) > {
3235 env_logger:: builder ( ) . filter_level ( LevelFilter :: Info ) . init ( ) ;
3336
34- musql (
35- matches. get_one :: < String > ( "base-path" ) . unwrap ( ) ,
36- matches. get_one :: < String > ( "database-path" ) . unwrap ( ) ,
37- )
37+ let args = Args :: parse ( ) ;
38+
39+ musql ( & args. base_path , & args. database_path )
3840}
3941
4042fn musql ( base_path : & str , database_path : & str ) -> Result < ( ) > {
0 commit comments