File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ static LIST_AFTER_HELP: &str = r#"EXAMPLES:
6565 leetcode list -c database List questions that in database category
6666 leetcode list -q eD List questions that with easy level and not done
6767 leetcode list -t linked-list List questions that under tag "linked-list"
68+ leetcode list -r 50 100 List questions that has id in between 50 and 100
6869"# ;
6970
7071/// implement Command trait for `list`
@@ -96,6 +97,14 @@ impl Command for ListCommand {
9697 . takes_value ( true )
9798 . help ( QUERY_HELP ) ,
9899 )
100+ . arg (
101+ Arg :: with_name ( "range" )
102+ . short ( "r" )
103+ . long ( "range" )
104+ . takes_value ( true )
105+ . min_values ( 2 )
106+ . help ( "Filter questions by id range" ) ,
107+ )
99108 . after_help ( LIST_AFTER_HELP )
100109 . arg (
101110 Arg :: with_name ( "stat" )
@@ -163,6 +172,16 @@ impl Command for ListCommand {
163172 crate :: helper:: filter ( & mut ps, query. to_string ( ) ) ;
164173 }
165174
175+ // filter range
176+ if m. is_present ( "range" ) {
177+ let range: Vec < _ > = m. values_of ( "range" ) ?. collect ( ) ;
178+ let num_range: Vec < i32 > = range
179+ . into_iter ( )
180+ . map ( |x| x. parse :: < i32 > ( ) . unwrap_or ( 0 ) )
181+ . collect ( ) ;
182+ ps. retain ( |x| num_range[ 0 ] <= x. fid && x. fid <= num_range[ 1 ] ) ;
183+ }
184+
166185 // retain if keyword exists
167186 if let Some ( keyword) = m. value_of ( "keyword" ) {
168187 ps. retain ( |x| x. name . contains ( & keyword) ) ;
You can’t perform that action at this time.
0 commit comments