summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2011-09-14 19:40:28 +0000
committerhallgren <hallgren@chalmers.se>2011-09-14 19:40:28 +0000
commit570afd870cace4606ab801edc9a619b94cfb7d12 (patch)
tree4900725b3746f10fd512d0ee0d3586e7760ec7b8 /src
parent553474d9dc48f5ebd3dcceec7b8132e614ed23f6 (diff)
GF shell command 'help -t2t' outputs help in txt2tags format
Diffstat (limited to 'src')
-rw-r--r--src/compiler/GF/Command/Commands.hs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/compiler/GF/Command/Commands.hs b/src/compiler/GF/Command/Commands.hs
index 4197e0c31..6d2ebcc08 100644
--- a/src/compiler/GF/Command/Commands.hs
+++ b/src/compiler/GF/Command/Commands.hs
@@ -83,9 +83,11 @@ lookCommand = Map.lookup
commandHelpAll :: PGFEnv -> [Option] -> String
commandHelpAll pgf opts = unlines
- [commandHelp (isOpt "full" opts) (co,info)
+ [commandHelp' opts (isOpt "full" opts) (co,info)
| (co,info) <- Map.assocs (allCommands pgf)]
+commandHelp' opts = if isOpt "t2t" opts then commandHelpTags else commandHelp
+
commandHelp :: Bool -> (String,CommandInfo) -> String
commandHelp full (co,info) = unlines $ [
co ++ ", " ++ longname info,
@@ -104,11 +106,11 @@ commandHelp full (co,info) = unlines $ [
commandHelpTags :: Bool -> (String,CommandInfo) -> String
commandHelpTags full (co,info) = unlines $ [
"#VSPACE","","#NOINDENT",
- lit co ++ " = " ++ lit (longname info) ++ ": " ++
+ lit co ++ equal (lit (longname info)) ++ ": " ++
"//" ++ synopsis info ++ ".//"] ++ if full then [
"","#TINY","",
explanation info,
- "- Syntax: ``" ++ syntax info ++ "``",
+ "- Syntax: " ++ lit (syntax info),
"- Options:\n" ++++
unlines [" | ``-" ++ o ++ "`` | " ++ e | (o,e) <- options info],
"- Flags:\n" ++++
@@ -119,6 +121,10 @@ commandHelpTags full (co,info) = unlines $ [
"", "#NORMAL", ""
] else []
where
+ equal "" = ""
+ equal s = " = " ++ s
+
+ lit "" = ""
lit s = "``" ++ s ++ "``"
type PGFEnv = (PGF, Map.Map Language Morpho)
@@ -415,7 +421,8 @@ allCommands env@(pgf, mos) = Map.fromList [
("changes","give a summary of changes from GF 2.9"),
("coding","give advice on character encoding"),
("full","give full information of the commands"),
- ("license","show copyright and license information")
+ ("license","show copyright and license information"),
+ ("t2t","output help in txt2tags format")
],
exec = \opts ts ->
let
@@ -425,7 +432,7 @@ allCommands env@(pgf, mos) = Map.fromList [
_ | isOpt "license" opts -> licenseMsg
[t] -> let co = getCommandOp (showExpr [] t) in
case lookCommand co (allCommands env) of ---- new map ??!!
- Just info -> commandHelp True (co,info)
+ Just info -> commandHelp' opts True (co,info)
_ -> "command not found"
_ -> commandHelpAll env opts
in return (fromString msg),