From 988498376202bdab23c572659bf4f2cac30dab86 Mon Sep 17 00:00:00 2001 From: aarne Date: Thu, 4 Sep 2008 09:03:02 +0000 Subject: [PATCH] convert all values in shell pipes to strings --- src/GF/Command/Commands.hs | 29 ++++++++++++++++++----------- 1 file 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"),