Fix switch command -v flag

This commit is contained in:
Eugene Yokota 2020-04-24 01:04:05 -04:00
parent 4c1c4e6710
commit 588d01b2dd
1 changed files with 7 additions and 2 deletions

View File

@ -54,12 +54,17 @@ object Cross {
}
}
val spacedVersion = if (spacePresent) version else version & spacedFirst(SwitchCommand)
val verbose = Parser.opt(token(Space ~> "-v"))
val verboseOpt = Parser.opt(token(Space ~> "-v"))
val optionalCommand = Parser.opt(token(Space ~> matched(state.combinedParser)))
(spacedVersion ~ verbose ~ optionalCommand).map {
val switch1 = (token(Space ~> "-v") ~> (Space ~> version) ~ optionalCommand) map {
case v ~ command =>
Switch(v, true, command)
}
val switch2 = (spacedVersion ~ verboseOpt ~ optionalCommand) map {
case v ~ verbose ~ command =>
Switch(v, verbose.isDefined, command)
}
switch1 | switch2
}
token(SwitchCommand ~> OptSpace) flatMap { sp =>