summaryrefslogtreecommitdiff
path: root/src-3.0/GF/Command/Abstract.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src-3.0/GF/Command/Abstract.hs')
-rw-r--r--src-3.0/GF/Command/Abstract.hs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src-3.0/GF/Command/Abstract.hs b/src-3.0/GF/Command/Abstract.hs
index 127cbf6e0..1f72688a0 100644
--- a/src-3.0/GF/Command/Abstract.hs
+++ b/src-3.0/GF/Command/Abstract.hs
@@ -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]