Append only commands to command history
This commit is contained in:
parent
81adcb6111
commit
5bbc069013
1 changed files with 9 additions and 7 deletions
16
app/Main.hs
16
app/Main.hs
|
|
@ -9,6 +9,7 @@ import Control.Monad.Trans.Maybe
|
|||
import Data.Char
|
||||
import Data.Time
|
||||
import System.Console.Haskeline
|
||||
import System.Console.Haskeline.History
|
||||
|
||||
type Input = InputT IO
|
||||
|
||||
|
|
@ -16,7 +17,7 @@ inputSettings :: Settings IO
|
|||
inputSettings = Settings
|
||||
{ complete = noCompletion
|
||||
, historyFile = Nothing
|
||||
, autoAddHistory = True
|
||||
, autoAddHistory = False
|
||||
}
|
||||
|
||||
{-
|
||||
|
|
@ -133,15 +134,16 @@ stats = undefined -- TODO: Use tierName
|
|||
run :: Elements -> InputT IO Elements
|
||||
run elms = do
|
||||
cmd <- getInputLine "%> "
|
||||
let logCmd command = modifyHistory $ addHistoryUnlessConsecutiveDupe command
|
||||
case trim ' ' . map toLower <$> cmd of
|
||||
Nothing -> return elms
|
||||
Just "" -> run elms
|
||||
Just "quit" -> return elms
|
||||
Just "q" -> return elms
|
||||
Just "learn" -> learn elms >>= run
|
||||
Just "l" -> learn elms >>= run
|
||||
Just "show" -> stats elms >> run elms
|
||||
Just "s" -> stats elms >> run elms
|
||||
Just "quit" -> logCmd "quit" >> return elms
|
||||
Just "q" -> logCmd "quit" >> return elms
|
||||
Just "learn" -> logCmd "learn" >> learn elms >>= run
|
||||
Just "l" -> logCmd "learn" >> learn elms >>= run
|
||||
Just "show" -> logCmd "show" >> stats elms >> run elms
|
||||
Just "s" -> logCmd "show" >> stats elms >> run elms
|
||||
Just x -> do
|
||||
outputStrLn $ "Unknown command " ++ show x ++ "."
|
||||
run elms
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue