module System.Console.Internal where
import Control.Exception (Exception)
import Data.Map (Map)
import Data.Typeable (Typeable)
import qualified System.Console.GetOpt as GetOpt
type UserCommand = [String]
data Action m
= Action
{
run :: [String] -> Settings -> m ()
, nonOptions :: [String]
, options :: [GetOpt.OptDescr Setting]
, ignoringOptions :: [GetOpt.OptDescr Setting]
}
data Identifier
= Short Char
| Long String
deriving (Eq,Ord)
type Setting
= (Identifier,Maybe String)
type Settings
= Map Identifier (Maybe String)
data Option a = Option
Identifier
(GetOpt.OptDescr Setting)
a
(Maybe String -> Either String a)
data Command m
= Command
{
name :: String
, description :: String
, action :: Action m
, shorten :: Bool
}
data ConsoleProgramException
= UnknownCommand String
deriving (Typeable)
instance Show ConsoleProgramException where
show (UnknownCommand c) = "Error: unused non-option or unrecognised command: " ++ c
instance Exception ConsoleProgramException