@@ -4,42 +4,42 @@ use anyhow::Result;
44use std:: fs;
55use std:: io;
66use std:: io:: { Read , Write } ;
7- use clap:: { App , AppSettings , Arg , SubCommand } ;
7+ use clap:: { Command , Arg } ;
88
99use mates:: cli;
1010use mates:: utils;
1111
1212fn main ( ) -> Result < ( ) > {
13- let app = App :: new ( "mates" )
13+ let app = Command :: new ( "mates" )
1414 . version ( env ! ( "CARGO_PKG_VERSION" ) )
1515 . author ( "Markus Unterwaditzer" )
1616 . about ( "A simple commandline addressbook" )
17- . setting ( AppSettings :: SubcommandRequired )
18- . subcommand ( SubCommand :: with_name ( "index" ) . about ( "Rewrite/create the index" ) )
17+ . subcommand_required ( true )
18+ . subcommand ( Command :: new ( "index" ) . about ( "Rewrite/create the index" ) )
1919 . subcommand (
20- SubCommand :: with_name ( "mutt-query" )
20+ Command :: new ( "mutt-query" )
2121 . about ( "Search for contact, output is usable for mutt's query_command." )
22- . arg ( Arg :: with_name ( "disable-empty-line" ) . long ( "disable-empty-line" ) . help ( "Disable printing an empty first line" ) )
23- . arg ( Arg :: with_name ( "query" ) . required ( true ) ) ,
22+ . arg ( Arg :: new ( "disable-empty-line" ) . long ( "disable-empty-line" ) . help ( "Disable printing an empty first line" ) )
23+ . arg ( Arg :: new ( "query" ) . required ( true ) ) ,
2424 )
2525 . subcommand (
26- SubCommand :: with_name ( "file-query" )
26+ Command :: new ( "file-query" )
2727 . about ( "Search for contact, return just the filename." )
28- . arg ( Arg :: with_name ( "query" ) . required ( true ) ) ,
28+ . arg ( Arg :: new ( "query" ) . required ( true ) ) ,
2929 )
3030 . subcommand (
31- SubCommand :: with_name ( "email-query" )
31+ Command :: new ( "email-query" )
3232 . about ( "Search for contact, return \" name <email>\" ." )
33- . arg ( Arg :: with_name ( "query" ) . required ( true ) ) ,
33+ . arg ( Arg :: new ( "query" ) . required ( true ) ) ,
3434 )
3535 . subcommand (
36- SubCommand :: with_name ( "add" )
36+ Command :: new ( "add" )
3737 . about ( "Take mail from stdin, add sender to contacts. Print filename." ) ,
3838 )
3939 . subcommand (
40- SubCommand :: with_name ( "edit" )
40+ Command :: new ( "edit" )
4141 . about ( "Open contact (given by filepath or search-string) interactively." )
42- . arg ( Arg :: with_name ( "file-or-query" ) . required ( true ) ) ,
42+ . arg ( Arg :: new ( "file-or-query" ) . required ( true ) ) ,
4343 )
4444 . get_matches ( ) ;
4545
@@ -51,29 +51,29 @@ fn main() -> Result<()> {
5151 } ;
5252
5353 match app. subcommand ( ) {
54- ( "index" , Some ( _args ) ) => {
54+ Some ( ( "index" , _ ) ) => {
5555 println ! (
5656 "Rebuilding index file \" {}\" ..." ,
5757 config. index_path. display( )
5858 ) ;
5959 cli:: build_index ( & config. index_path , & config. vdir_path ) ?;
6060 }
61- ( "mutt-query" , Some ( args) ) => {
61+ Some ( ( "mutt-query" , args) ) => {
6262 if let Some ( value) = args. value_of ( "query" ) {
6363 cli:: mutt_query ( & config, args. is_present ( "disable-empty-line" ) , value) ?
6464 }
6565 }
66- ( "file-query" , Some ( args) ) => {
66+ Some ( ( "file-query" , args) ) => {
6767 if let Some ( value) = args. value_of ( "query" ) {
6868 cli:: file_query ( & config, value) ?
6969 }
7070 }
71- ( "email-query" , Some ( args) ) => {
71+ Some ( ( "email-query" , args) ) => {
7272 if let Some ( value) = args. value_of ( "query" ) {
7373 cli:: email_query ( & config, value) ?
7474 }
7575 }
76- ( "add" , Some ( .. ) ) => {
76+ Some ( ( "add" , _ ) ) => {
7777 let stdin = io:: stdin ( ) ;
7878 let mut email = String :: new ( ) ;
7979 stdin. lock ( ) . read_to_string ( & mut email) ?;
@@ -88,7 +88,7 @@ fn main() -> Result<()> {
8888 let index_entry = utils:: index_item_from_contact ( & contact) ?;
8989 index_fp. write_all ( index_entry. as_bytes ( ) ) ?;
9090 }
91- ( "edit" , Some ( args) ) => {
91+ Some ( ( "edit" , args) ) => {
9292 if let Some ( value) = args. value_of ( "file-or-query" ) {
9393 cli:: edit_contact ( & config, value) ?
9494 }
0 commit comments