@@ -3,7 +3,6 @@ pub mod parse;
33pub mod utils;
44
55// Reexport some crates for the generated main
6- pub use chrono;
76pub use clap;
87pub use colored;
98
@@ -46,7 +45,13 @@ pub fn args(year: u16) -> App<'static> {
4645 . long ( "bench" )
4746 . about ( "Run criterion benchmarks" ) ,
4847 )
49- . arg ( Arg :: new ( "all" ) . long ( "all" ) . about ( "Run all days" ) )
48+ . arg (
49+ Arg :: new ( "all" )
50+ . short ( 'a' )
51+ . long ( "all" )
52+ . conflicts_with ( "days" )
53+ . about ( "Run all days" ) ,
54+ )
5055}
5156
5257#[ macro_export]
@@ -56,22 +61,16 @@ macro_rules! base_main {
5661 use std:: io:: Read ;
5762 use std:: time:: Instant ;
5863
59- use $crate:: chrono:: { prelude:: * , FixedOffset , TimeZone } ;
60-
6164 use $crate:: { bench_day, extract_day, parse, run_day} ;
6265
6366 const YEAR : u16 = $year;
6467
6568 fn main( ) {
6669 let mut opt = $crate:: args( YEAR ) . get_matches( ) ;
6770
68-
6971 if opt. is_present( "bench" ) {
7072 bench( ) ;
7173 } else {
72- let est = FixedOffset :: west( 5 * 3600 ) . from_utc_datetime( & Utc :: now( ) . naive_utc( ) ) ;
73- let today = est. day( ) . to_string( ) ;
74-
7574 let days: Vec <_> = {
7675 if let Some ( opt_days) = opt. values_of( "days" ) {
7776 let opt_days: Vec <_> = opt_days. collect( ) ;
@@ -92,13 +91,17 @@ macro_rules! base_main {
9291 . filter( |day| days. contains( & format!( "day{}" , day) . as_str( ) ) )
9392 . collect( )
9493 } else {
95- if !opt. is_present( "all" ) && est. year( ) == YEAR as i32 && est. month( ) == 12 && est. day( ) <= 25 {
96- vec![ & today]
97- } else {
94+ if opt. is_present( "all" ) {
9895 parse!( extract_day { } ; $( $tail ) * )
9996 . iter( )
10097 . map( |s| & s[ 3 ..] )
10198 . collect( )
99+ } else {
100+ vec![ parse!( extract_day { } ; $( $tail ) * )
101+ . iter( )
102+ . map( |s| & s[ 3 ..] )
103+ . last( )
104+ . expect( "No day implemenations found" ) ]
102105 }
103106 }
104107 } ;
0 commit comments