Format mima state

Also, use the new formatter in mima-run (and while we're at it, clean up flag
file loading and prepare for symbol file loading).
This commit is contained in:
Joscha 2019-11-19 10:24:53 +00:00
parent 45ec7d1708
commit 8bfce48a7f
4 changed files with 273 additions and 41 deletions

28
src/Mima/Options.hs Normal file
View file

@ -0,0 +1,28 @@
module Mima.Options
( switchWithNo
, formatConfigParser
) where
import Options.Applicative
import Mima.Format.State
switchWithNo :: String -> Bool -> Mod FlagFields Bool -> Parser Bool
switchWithNo name True fields = flag' False (long ("no-" ++ name) <> fields)
<|> flag True True (long name <> fields)
switchWithNo name False fields = flag' True (long name <> fields)
<|> flag False False (long ("no-" ++ name) <> fields)
formatConfigParser :: Parser FormatConfig
formatConfigParser = FormatConfig
<$> switchWithNo "sparse" False mempty
<*> switchWithNo "register-flags" True mempty
<*> switchWithNo "memory-flags" True mempty
<*> switchWithNo "address-dec" True mempty
<*> switchWithNo "address-hex" True mempty
<*> switchWithNo "address-bin" False mempty
<*> switchWithNo "word-dec" True mempty
<*> switchWithNo "word-hex" True mempty
<*> switchWithNo "word-bin" False mempty
<*> switchWithNo "instructions" True mempty
<*> switchWithNo "labels" True mempty