11use advent_of_code:: template:: commands:: { all, download, read, scaffold, solve} ;
22use args:: { parse, AppArguments } ;
33
4+ #[ cfg( feature = "today" ) ]
5+ use advent_of_code:: template:: Day ;
6+ #[ cfg( feature = "today" ) ]
7+ use std:: process;
8+
49mod args {
510 use advent_of_code:: template:: Day ;
611 use std:: process;
@@ -27,6 +32,8 @@ mod args {
2732 release : bool ,
2833 time : bool ,
2934 } ,
35+ #[ cfg( feature = "today" ) ]
36+ Today ,
3037 }
3138
3239 pub fn parse ( ) -> Result < AppArguments , Box < dyn std:: error:: Error > > {
@@ -54,6 +61,8 @@ mod args {
5461 time : args. contains ( "--time" ) ,
5562 dhat : args. contains ( "--dhat" ) ,
5663 } ,
64+ #[ cfg( feature = "today" ) ]
65+ Some ( "today" ) => AppArguments :: Today ,
5766 Some ( x) => {
5867 eprintln ! ( "Unknown command: {x}" ) ;
5968 process:: exit ( 1 ) ;
@@ -96,6 +105,23 @@ fn main() {
96105 dhat,
97106 submit,
98107 } => solve:: handle ( day, release, time, dhat, submit) ,
108+ #[ cfg( feature = "today" ) ]
109+ AppArguments :: Today => {
110+ match Day :: today ( ) {
111+ Some ( day) => {
112+ scaffold:: handle ( day) ;
113+ download:: handle ( day) ;
114+ read:: handle ( day)
115+ }
116+ None => {
117+ eprintln ! (
118+ "`today` command can only be run between the 1st and \
119+ the 25th of december. Please use `scaffold` with a specific day."
120+ ) ;
121+ process:: exit ( 1 )
122+ }
123+ } ;
124+ }
99125 } ,
100126 } ;
101127}
0 commit comments