summaryrefslogtreecommitdiff
path: root/src/GF/Command
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-09-04 09:03:02 +0000
committeraarne <aarne@cs.chalmers.se>2008-09-04 09:03:02 +0000
commitb3803424ff7c82f340736842bb98fbd622c0e8bf (patch)
tree2ee8d6a7fb8906b947dbfa9104a97b7126e0fb2d /src/GF/Command
parent207ddc4cb687159d714e14ad0e90444b393c268a (diff)
convert all values in shell pipes to strings
Diffstat (limited to 'src/GF/Command')
-rw-r--r--src/GF/Command/Commands.hs29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/GF/Command/Commands.hs b/src/GF/Command/Commands.hs
index fe3532354..c99b3c198 100644
--- a/src/GF/Command/Commands.hs
+++ b/src/GF/Command/Commands.hs
@@ -199,15 +199,18 @@ allCommands enc pgf = Map.fromList [
("full","give full information of the commands"),
("license","show copyright and license information")
],
- exec = \opts ts -> return ([], case ts of
- _ | isOpt "changes" opts -> changesMsg
- _ | isOpt "coding" opts -> codingMsg
- _ | isOpt "license" opts -> licenseMsg
- [t] -> let co = getCommandOp (showTree t) in
- case lookCommand co (allCommands enc pgf) of ---- new map ??!!
- Just info -> commandHelp True (co,info)
- _ -> "command not found"
- _ -> commandHelpAll enc pgf opts)
+ exec = \opts ts ->
+ let
+ msg = case ts of
+ _ | isOpt "changes" opts -> changesMsg
+ _ | isOpt "coding" opts -> codingMsg
+ _ | isOpt "license" opts -> licenseMsg
+ [t] -> let co = getCommandOp (showTree t) in
+ case lookCommand co (allCommands enc pgf) of ---- new map ??!!
+ Just info -> commandHelp True (co,info)
+ _ -> "command not found"
+ _ -> commandHelpAll enc pgf opts
+ in return (fromString msg)
}),
("i", emptyCommandInfo {
longname = "import",
@@ -561,8 +564,8 @@ allCommands enc pgf = Map.fromList [
fromTrees ts = (ts,unlines (map showTree ts))
fromStrings ss = (map (Lit . LStr) ss, unlines ss)
fromString s = ([Lit (LStr s)], s)
- toStrings ts = [s | Lit (LStr s) <- ts]
- toString ts = unwords [s | Lit (LStr s) <- ts]
+ toStrings = map showAsString
+ toString = unwords . toStrings
prGrammar opts = case opts of
_ | isOpt "cats" opts -> unwords $ categories pgf
@@ -581,6 +584,10 @@ allCommands enc pgf = Map.fromList [
stringOps opts s = foldr app s (reverse opts) where
app f = maybe id id (stringOp f)
+ showAsString t = case t of
+ Lit (LStr s) -> s
+ _ -> "\n" ++ showTree t --- newline needed in other cases than the first
+
stringOpOptions = [
("bind","bind tokens separated by Prelude.BIND, i.e. &+"),
("chars","lexer that makes every non-space character a token"),