diff options
Diffstat (limited to 'main/Main.hs')
-rw-r--r-- | main/Main.hs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/main/Main.hs b/main/Main.hs index 90e4079..5dbad60 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -140,8 +140,11 @@ main = do else interactiveLoop st opts +inputSettings :: Settings IO +inputSettings = setComplete commandCompletion $ defaultSettings + interactiveLoop :: Storage -> Options -> IO () -interactiveLoop st opts = runInputT defaultSettings $ do +interactiveLoop st opts = runInputT inputSettings $ do erebosHead <- liftIO $ loadLocalStateHead st outputStrLn $ T.unpack $ displayIdentity $ headLocalIdentity erebosHead @@ -322,6 +325,14 @@ commands = #endif ] +commandCompletion :: CompletionFunc IO +commandCompletion = completeWordWithPrev Nothing [ ' ', '\t', '\n', '\r' ] $ curry $ \case + ([], '/':pref) -> return . map (simpleCompletion . ('/':)) . filter (pref `isPrefixOf`) $ sortedCommandNames + _ -> return [] + where + sortedCommandNames = sort $ map fst commands + + cmdUnknown :: String -> Command cmdUnknown cmd = liftIO $ putStrLn $ "Unknown command: " ++ cmd |