Friday, November 28, 2014

haskell shellac skeleton sample

module ShellacTest where

import System.Console.Shell
import System.Console.Shell.ShellMonad
import System.Console.Shell.Backend.Basic

react :: String -> Sh () ()
react s = shellPutStrLn $ "exec command: " ++ s

main :: IO ()
main = do
  runShell shellDescr' basicBackend ()
  where shellDescr = mkShellDescription shellCommands react
        shellDescr' = shellDescr {greetingText = Just "welcome to shellac\n  type \"quit\" or \"exit\" to quit\n  or \"?\" for help\n",
                                  prompt = \_ -> return "prompt> ",
                                  commandStyle = OnlyCommands,
                                  shellCommands = shellCommands
                                 }
        shellCommands = [exitCommand "quit", exitCommand "exit",
                         helpCommand "?"]

No comments: