save a copy of the database on start of new season

This commit is contained in:
Jonathan Lamothe
2020-01-14 03:21:40 -05:00
parent 2bf8d15bd4
commit 39646f3fa7
3 changed files with 35 additions and 19 deletions

View File

@@ -48,7 +48,7 @@ module Mtlstats.Prompt (
import Control.Monad (when)
import Control.Monad.Extra (whenJust)
import Control.Monad.Trans.State (gets, modify)
import Data.Char (isDigit, toUpper)
import Data.Char (isAlphaNum, isDigit, toUpper)
import Lens.Micro ((^.), (&), (.~), (?~), (%~))
import Lens.Micro.Extras (view)
import Text.Read (readMaybe)
@@ -171,7 +171,18 @@ numPromptWithFallback pStr fallback act = Prompt
-- | Prompts the user for a filename to save a backup of the database
-- to
newSeasonPrompt :: Prompt
newSeasonPrompt = undefined
newSeasonPrompt = prompt
{ promptProcessChar = \ch str -> if isAlphaNum ch
then str ++ [toUpper ch]
else str
}
where
prompt = strPrompt "Filename to save database: " $ \fn ->
if null fn
then modify backHome
else do
saveDatabase $ fn ++ ".json"
modify $ progMode .~ NewSeason True
-- | Builds a selection prompt
selectPrompt :: SelectParams a -> Prompt