mirror of
https://github.com/redelmann/scat
synced 2025-01-10 06:34:20 +01:00
Asking for schema first instead of service. Switched to a list of schemas.
This commit is contained in:
parent
e082a68c0f
commit
a2eb523d5a
41
src/Scat.hs
41
src/Scat.hs
@ -54,8 +54,8 @@ main = getOptions >>= runReaderT scat
|
|||||||
-- | Main program.
|
-- | Main program.
|
||||||
scat :: Scat ()
|
scat :: Scat ()
|
||||||
scat = do
|
scat = do
|
||||||
k <- getService
|
|
||||||
s <- getSchema
|
s <- getSchema
|
||||||
|
k <- getService
|
||||||
pw <- getPassword
|
pw <- getPassword
|
||||||
c <- getCode
|
c <- getCode
|
||||||
printVerbose "Generated password:\n"
|
printVerbose "Generated password:\n"
|
||||||
@ -147,33 +147,24 @@ getCode = do
|
|||||||
Nothing -> prompt Erased "Code: "
|
Nothing -> prompt Erased "Code: "
|
||||||
else return ""
|
else return ""
|
||||||
|
|
||||||
|
|
||||||
|
-- | Lists all the available schemas.
|
||||||
|
schemas :: [(String, Scat Schema)]
|
||||||
|
schemas =
|
||||||
|
[ ("safe", return safe)
|
||||||
|
, ("alpha", return alphanumeric)
|
||||||
|
, ("parano", return paranoiac)
|
||||||
|
, ("pin", return pin)
|
||||||
|
, ("lock", return androidPatternLock)
|
||||||
|
, ("diceware", liftIO diceware)
|
||||||
|
, ("pokemons", liftIO pokemons) ]
|
||||||
|
|
||||||
-- | Gets the schema to generate the new password.
|
-- | Gets the schema to generate the new password.
|
||||||
getSchema :: Scat Schema
|
getSchema :: Scat Schema
|
||||||
getSchema = do
|
getSchema = do
|
||||||
name <- fmap schema ask
|
name <- fmap schema ask
|
||||||
case name of
|
case lookup name schemas of
|
||||||
-- Safe, the default.
|
Just s -> s
|
||||||
"safe" -> return safe
|
Nothing -> liftIO $ do
|
||||||
|
|
||||||
-- Alphanumeric.
|
|
||||||
"alpha" -> return alphanumeric
|
|
||||||
|
|
||||||
-- Paranoiac
|
|
||||||
"parano" -> return paranoiac
|
|
||||||
|
|
||||||
-- PIN.
|
|
||||||
"pin" -> return pin
|
|
||||||
|
|
||||||
-- Pattern lock
|
|
||||||
"lock" -> return androidPatternLock
|
|
||||||
|
|
||||||
-- Passphrase using Diceware's list.
|
|
||||||
"diceware" -> liftIO diceware
|
|
||||||
|
|
||||||
-- Passphrase using Pokemons.
|
|
||||||
"pokemons" -> liftIO pokemons
|
|
||||||
|
|
||||||
-- Unkown.
|
|
||||||
_ -> liftIO $ do
|
|
||||||
hPutStrLn stderr "Error: Unknown schema"
|
hPutStrLn stderr "Error: Unknown schema"
|
||||||
exitFailure
|
exitFailure
|
||||||
|
Loading…
Reference in New Issue
Block a user