summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Command/Abstract.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2015-08-12 11:05:08 +0000
committerhallgren <hallgren@chalmers.se>2015-08-12 11:05:08 +0000
commit6fff2def393663522f86e13e2536a9e111e8b2cd (patch)
tree777c40abe073299992f937f025b239e448672f59 /src/compiler/GF/Command/Abstract.hs
parent063912c3861d73c0b3cc036394476a4af8eec782 (diff)
GF shell: source commands (cc, sd, so, ss & dg) can now be used in pipes
These commands are now implemented as regular commands (i.e. using the CommandInfo data type) in the new module GF.Command.SourceCommands. The list of commands exported from GF.Command.Commmands now called pgfCommands instead of allCommands. The list allCommands of all commands is now assembled from sourceCommands, pgfCommands, commonCommands and helpCommand in GF.Interactive.
Diffstat (limited to 'src/compiler/GF/Command/Abstract.hs')
-rw-r--r--src/compiler/GF/Command/Abstract.hs18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/compiler/GF/Command/Abstract.hs b/src/compiler/GF/Command/Abstract.hs
index 5035a33d3..0a664d1ca 100644
--- a/src/compiler/GF/Command/Abstract.hs
+++ b/src/compiler/GF/Command/Abstract.hs
@@ -43,14 +43,20 @@ valIntOpts flag def opts =
valStrOpts :: String -> String -> [Option] -> String
valStrOpts flag def opts =
- case [v | OFlag f v <- opts, f == flag] of
- (VStr v:_) -> v
- (VId v:_) -> v
- (VInt v:_) -> show v
- _ -> def
+ case listFlags flag opts of
+ v:_ -> valueString v
+ _ -> def
+
+listFlags flag opts = [v | OFlag f v <- opts, f == flag]
+
+valueString v =
+ case v of
+ VStr v -> v
+ VId v -> v
+ VInt v -> show v
isOpt :: String -> [Option] -> Bool
-isOpt o opts = elem o [x | OOpt x <- opts]
+isOpt o opts = elem (OOpt o) opts
isFlag :: String -> [Option] -> Bool
isFlag o opts = elem o [x | OFlag x _ <- opts]