mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
Make flag value checking depend on the command. Fixed spurious error messages with pm -printer values.
This commit is contained in:
@@ -90,19 +90,21 @@ isValidOption st co op = case op of
|
|||||||
testErr (elem o $ optsOf co) ("invalid option:" +++ prOpt op)
|
testErr (elem o $ optsOf co) ("invalid option:" +++ prOpt op)
|
||||||
Opt (o,[x]) -> do
|
Opt (o,[x]) -> do
|
||||||
testErr (elem o (flagsOf co)) ("invalid flag:" +++ o)
|
testErr (elem o (flagsOf co)) ("invalid flag:" +++ o)
|
||||||
testValidFlag st o x
|
testValidFlag st co o x
|
||||||
_ -> Bad $ "impossible option" +++ prOpt op
|
_ -> Bad $ "impossible option" +++ prOpt op
|
||||||
where
|
where
|
||||||
optsOf co = ("tr" :) $ fst $ optionsOfCommand co
|
optsOf co = ("tr" :) $ fst $ optionsOfCommand co
|
||||||
flagsOf co = snd $ optionsOfCommand co
|
flagsOf co = snd $ optionsOfCommand co
|
||||||
|
|
||||||
testValidFlag :: ShellState -> OptFunId -> String -> Err ()
|
testValidFlag :: ShellState -> Command -> OptFunId -> String -> Err ()
|
||||||
testValidFlag st f x = case f of
|
testValidFlag st co f x = case f of
|
||||||
"cat" -> testIn (map prQIdent_ (allCategories st))
|
"cat" -> testIn (map prQIdent_ (allCategories st))
|
||||||
"lang" -> testIn (map prt (allLanguages st))
|
"lang" -> testIn (map prt (allLanguages st))
|
||||||
"res" -> testIn (map prt (allResources (srcModules st)))
|
"res" -> testIn (map prt (allResources (srcModules st)))
|
||||||
"number" -> testN
|
"number" -> testN
|
||||||
"printer" -> testInc customGrammarPrinter
|
"printer" -> case co of
|
||||||
|
CPrintGrammar -> testInc customGrammarPrinter
|
||||||
|
CPrintMultiGrammar -> testInc customMultiGrammarPrinter
|
||||||
"lexer" -> testInc customTokenizer
|
"lexer" -> testInc customTokenizer
|
||||||
"unlexer" -> testInc customUntokenizer
|
"unlexer" -> testInc customUntokenizer
|
||||||
"depth" -> testN
|
"depth" -> testN
|
||||||
|
|||||||
Reference in New Issue
Block a user