22use super :: Command ;
33use crate :: err:: Error ;
44use async_trait:: async_trait;
5- use clap:: { Arg , ArgMatches , Command as ClapCommand } ;
5+ use clap:: { Arg , ArgAction , ArgMatches , Command as ClapCommand } ;
66/// Abstract pick command
77///
88/// ```sh
@@ -73,8 +73,8 @@ impl Command for PickCommand {
7373 Arg :: new ( "daily" )
7474 . short ( 'd' )
7575 . long ( "daily" )
76- . num_args ( 1 )
77- . help ( "Pick today's daily challenge" ) ,
76+ . help ( "Pick today's daily challenge" )
77+ . action ( ArgAction :: SetTrue ) ,
7878 )
7979 }
8080
@@ -96,7 +96,11 @@ impl Command for PickCommand {
9696 #[ cfg( feature = "pym" ) ]
9797 {
9898 if m. contains_id ( "plan" ) {
99- let ids = crate :: pym:: exec ( m. get_one :: < & str > ( "plan" ) . unwrap_or ( & "" ) ) ?;
99+ let ids = crate :: pym:: exec (
100+ m. get_one :: < String > ( "plan" )
101+ . map ( |s| s. as_str ( ) )
102+ . unwrap_or ( "" ) ,
103+ ) ?;
100104 crate :: helper:: squash ( & mut problems, ids) ?;
101105 }
102106 }
@@ -105,14 +109,17 @@ impl Command for PickCommand {
105109 if m. contains_id ( "tag" ) {
106110 let ids = cache
107111 . clone ( )
108- . get_tagged_questions ( m. get_one :: < & str > ( "tag" ) . unwrap_or ( & "" ) )
112+ . get_tagged_questions ( m. get_one :: < String > ( "tag" ) . map ( |s| s . as_str ( ) ) . unwrap_or ( "" ) )
109113 . await ?;
110114 crate :: helper:: squash ( & mut problems, ids) ?;
111115 }
112116
113117 // query filter
114118 if m. contains_id ( "query" ) {
115- let query = m. get_one :: < & str > ( "query" ) . ok_or ( Error :: NoneError ) ?;
119+ let query = m
120+ . get_one :: < String > ( "query" )
121+ . map ( |s| s. as_str ( ) )
122+ . ok_or ( Error :: NoneError ) ?;
116123 crate :: helper:: filter ( & mut problems, query. to_string ( ) ) ;
117124 }
118125
@@ -123,7 +130,8 @@ impl Command for PickCommand {
123130 } ;
124131
125132 let fid = m
126- . get_one :: < & str > ( "id" )
133+ . get_one :: < String > ( "id" )
134+ . map ( |s| s. as_str ( ) )
127135 . and_then ( |id| id. parse :: < i32 > ( ) . ok ( ) )
128136 . or ( daily_id)
129137 . unwrap_or_else ( || {
0 commit comments