complete word completion in the shell. works for commands, flags, options, abstract syntax identifiers and NL strings

This commit is contained in:
kr.angelov
2008-06-05 11:29:08 +00:00
parent f5fd3aa603
commit 11f24097b4
5 changed files with 120 additions and 22 deletions

View File

@@ -26,3 +26,23 @@ data Argument
= AExp Exp
| ANoArg
deriving (Eq,Ord,Show)
valIdOpts :: String -> String -> [Option] -> String
valIdOpts flag def opts = case valOpts flag (VId def) opts of
VId v -> v
_ -> def
valIntOpts :: String -> Integer -> [Option] -> Int
valIntOpts flag def opts = fromInteger $ case valOpts flag (VInt def) opts of
VInt v -> v
_ -> def
valOpts :: String -> Value -> [Option] -> Value
valOpts flag def opts = case lookup flag flags of
Just v -> v
_ -> def
where
flags = [(f,v) | OFlag f v <- opts]
isOpt :: String -> [Option] -> Bool
isOpt o opts = elem o [x | OOpt x <- opts]