summaryrefslogtreecommitdiff
path: root/src-3.0/GF/Command
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@chalmers.se>2008-06-05 11:29:08 +0000
committerkr.angelov <kr.angelov@chalmers.se>2008-06-05 11:29:08 +0000
commit11f24097b470122e2f3197bce3e6931701a68cc4 (patch)
tree51d752fdb0b9d5e80fb890b16b0721a4d56a3df7 /src-3.0/GF/Command
parentf5fd3aa603bf736e47a6fdc6d9bf719ecef9d628 (diff)
complete word completion in the shell. works for commands, flags, options, abstract syntax identifiers and NL strings
Diffstat (limited to 'src-3.0/GF/Command')
-rw-r--r--src-3.0/GF/Command/Abstract.hs20
-rw-r--r--src-3.0/GF/Command/Commands.hs20
-rw-r--r--src-3.0/GF/Command/Parse.hs2
3 files changed, 21 insertions, 21 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]
diff --git a/src-3.0/GF/Command/Commands.hs b/src-3.0/GF/Command/Commands.hs
index ceabbde7b..e97c54861 100644
--- a/src-3.0/GF/Command/Commands.hs
+++ b/src-3.0/GF/Command/Commands.hs
@@ -64,26 +64,6 @@ commandHelp full (co,info) = unlines $ [
"flags: " ++ unwords (flags info)
] else []
-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]
-
-- this list must be kept sorted by the command name!
allCommands :: PGF -> Map.Map String CommandInfo
allCommands pgf = Map.fromAscList [
diff --git a/src-3.0/GF/Command/Parse.hs b/src-3.0/GF/Command/Parse.hs
index e3cc21cca..dfab70128 100644
--- a/src-3.0/GF/Command/Parse.hs
+++ b/src-3.0/GF/Command/Parse.hs
@@ -1,4 +1,4 @@
-module GF.Command.Parse(readCommandLine) where
+module GF.Command.Parse(readCommandLine, pCommand) where
import PGF.ExprSyntax
import GF.Command.Abstract