Add help for formatting options

This commit is contained in:
Joscha 2019-11-19 10:59:30 +00:00
parent 8bfce48a7f
commit 0d18329354
2 changed files with 33 additions and 16 deletions

View file

@ -71,7 +71,7 @@ settingsParser = Settings
<*> formatConfigParser
opts :: ParserInfo Settings
opts = info (helper <*> settingsParser) $ fullDesc <> failureCode 1
opts = info (helper <*> settingsParser) $ fullDesc <> failureCode 1 <> footer formatConfigHelp
{- Loading the flag file -}

View file

@ -1,5 +1,6 @@
module Mima.Options
( switchWithNo
, formatConfigHelp
, formatConfigParser
) where
@ -8,21 +9,37 @@ 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)
switchWithNo name defaultValue fields
| defaultValue = flag' False noMod <|> flag True True yesMod
| otherwise = flag' True yesMod <|> flag False False noMod
where
yesMod = long name <> hidden <> fields
noMod = long ("no-" ++ name) <> hidden
formatConfigHelp :: String
formatConfigHelp = "All options labeled with 'Formatting:' can be negated by prepending 'no-' to their name (e. g. '--sparse' becomes '--no-sparse')."
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
<$> switchWithNo "sparse" False
(help "Formatting: Omit uninteresting addresses")
<*> switchWithNo "register-flags" True
(help "Formatting: For each address, show all the memory flags that are active for that address")
<*> switchWithNo "memory-flags" True
(help "Formatting: For each address, show all registers currently pointing to that address")
<*> switchWithNo "address-dec" True
(help "Formatting: Display addresses in decimal")
<*> switchWithNo "address-hex" True
(help "Formatting: Display addresses in hexadecimal")
<*> switchWithNo "address-bin" False
(help "Formatting: Display addresses in binary")
<*> switchWithNo "word-dec" True
(help "Formatting: Display words in decimal")
<*> switchWithNo "word-hex" True
(help "Formatting: Display words in hexadecimal")
<*> switchWithNo "word-bin" False
(help "Formatting: Display words in binary")
<*> switchWithNo "instructions" True
(help "Formatting: Show instructions")
<*> switchWithNo "labels" True
(help "Formatting: Show labels from the symbol file")