prompt for database name

This commit is contained in:
Jonathan Lamothe
2020-03-11 03:56:58 -04:00
parent 87336dcd1d
commit 1e8473538a

View File

@@ -32,6 +32,7 @@ module Mtlstats.Prompt (
namePrompt, namePrompt,
numPrompt, numPrompt,
numPromptWithFallback, numPromptWithFallback,
dbNamePrompt,
selectPrompt, selectPrompt,
-- * Individual prompts -- * Individual prompts
getDBPrompt, getDBPrompt,
@@ -169,6 +170,19 @@ numPromptWithFallback pStr fallback act = Prompt
, promptSpecialKey = const $ return () , promptSpecialKey = const $ return ()
} }
-- | Prompts for a database name
dbNamePrompt
:: String
-- ^ The prompt string
-> (String -> Action ())
-- ^ The callback to pass the result to
-> Prompt
dbNamePrompt pStr act = (strPrompt pStr act)
{ promptProcessChar = \ch -> if isAlphaNum ch || ch == '-'
then (++[toUpper ch])
else id
}
-- | Prompts the user for a filename to save a backup of the database -- | Prompts the user for a filename to save a backup of the database
-- to -- to
newSeasonPrompt :: Prompt newSeasonPrompt :: Prompt
@@ -227,7 +241,8 @@ selectPrompt params = Prompt
-- | Prompts for the database to load -- | Prompts for the database to load
getDBPrompt :: Prompt getDBPrompt :: Prompt
getDBPrompt = undefined getDBPrompt = dbNamePrompt "Season database to load: " $
modify . (dbName .~)
-- | Prompts for a new player's number -- | Prompts for a new player's number
playerNumPrompt :: Prompt playerNumPrompt :: Prompt