imp: cli: Let --today option handle smart dates, determined relative to
the current date.
This commit is contained in:
		
							parent
							
								
									7a249cffe9
								
							
						
					
					
						commit
						54f2600db2
					
				| @ -79,7 +79,7 @@ import qualified Control.Exception as C | |||||||
| import Control.Monad (when) | import Control.Monad (when) | ||||||
| import Data.Char | import Data.Char | ||||||
| import Data.Default | import Data.Default | ||||||
| import Data.Either (isRight) | import Data.Either (fromRight, isRight) | ||||||
| import Data.Functor.Identity (Identity) | import Data.Functor.Identity (Identity) | ||||||
| import "base-compat-batteries" Data.List.Compat | import "base-compat-batteries" Data.List.Compat | ||||||
| import Data.List.Extra (groupSortOn, nubSort) | import Data.List.Extra (groupSortOn, nubSort) | ||||||
| @ -467,9 +467,11 @@ replaceNumericFlags = map replace | |||||||
| -- Also records the terminal width, if supported. | -- Also records the terminal width, if supported. | ||||||
| rawOptsToCliOpts :: RawOpts -> IO CliOpts | rawOptsToCliOpts :: RawOpts -> IO CliOpts | ||||||
| rawOptsToCliOpts rawopts = do | rawOptsToCliOpts rawopts = do | ||||||
|   day <- case maybestringopt "today" rawopts of |   currentDay <- getCurrentDay | ||||||
|               Nothing -> getCurrentDay |   let day = case maybestringopt "today" rawopts of | ||||||
|               Just d  -> maybe (fail $ "Unable to parse date \"" ++ d ++ "\"") pure $ parsedateM d  -- PARTIAL: |               Nothing -> currentDay | ||||||
|  |               Just d  -> fromRight (error' $ "Unable to parse date \"" ++ d ++ "\"") -- PARTIAL: | ||||||
|  |                          $ fixSmartDateStrEither' currentDay (T.pack d) | ||||||
|   let iopts = rawOptsToInputOpts day rawopts |   let iopts = rawOptsToInputOpts day rawopts | ||||||
|   rspec <- either fail pure $ rawOptsToReportSpec day rawopts  -- PARTIAL: |   rspec <- either fail pure $ rawOptsToReportSpec day rawopts  -- PARTIAL: | ||||||
|   mcolumns <- readMay <$> getEnvSafe "COLUMNS" |   mcolumns <- readMay <$> getEnvSafe "COLUMNS" | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user