fix:help: -i and -m were always showing help's help [#2399]
This commit is contained in:
parent
ce0cd344b5
commit
3f7a9f97f9
@ -18,28 +18,27 @@ module Hledger.Cli.Commands.Help (
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
import Safe (headMay)
|
||||||
import System.Console.CmdArgs.Explicit
|
import System.Console.CmdArgs.Explicit
|
||||||
import System.Environment
|
import System.Environment
|
||||||
import System.IO
|
import System.IO
|
||||||
|
|
||||||
import Hledger.Utils (embedFileRelative)
|
|
||||||
import Hledger.Data.RawOptions
|
|
||||||
import Hledger.Data.Types
|
|
||||||
import Hledger.Cli.CliOptions
|
import Hledger.Cli.CliOptions
|
||||||
import Hledger.Cli.DocFiles
|
import Hledger.Cli.DocFiles
|
||||||
import Safe (headMay)
|
import Hledger.Data.RawOptions
|
||||||
|
import Hledger.Data.Types
|
||||||
|
import Hledger.Utils (embedFileRelative)
|
||||||
--import Hledger.Utils.Debug
|
--import Hledger.Utils.Debug
|
||||||
|
|
||||||
helpmode = hledgerCommandMode
|
helpmode = hledgerCommandMode
|
||||||
$(embedFileRelative "Hledger/Cli/Commands/Help.txt")
|
$(embedFileRelative "Hledger/Cli/Commands/Help.txt")
|
||||||
[flagNone ["i"] (setboolopt "info") "show the manual with info"
|
-- The help-* names avoid a clash with the --info and --man flags handled in Cli.hs.
|
||||||
,flagNone ["m"] (setboolopt "man") "show the manual with man"
|
[flagNone ["i"] (setboolopt "help-i") "show the manual with info"
|
||||||
,flagNone ["p"] (setboolopt "pager") "show the manual with $PAGER or less\n(less is always used if TOPIC is specified)"
|
,flagNone ["m"] (setboolopt "help-m") "show the manual with man"
|
||||||
|
,flagNone ["p"] (setboolopt "help-p") "show the manual with $PAGER or less\n(less is always used if TOPIC is specified)"
|
||||||
]
|
]
|
||||||
[(helpflagstitle, helpflags)]
|
[(helpflagstitle, helpflags)]
|
||||||
[
|
[]
|
||||||
flagReq ["debug"] (\s opts -> Right $ setopt "debug" s opts) "[N]" "show debug output (levels 1-9, default: 1)"
|
|
||||||
]
|
|
||||||
([], Just $ argsFlag "[TOPIC]")
|
([], Just $ argsFlag "[TOPIC]")
|
||||||
|
|
||||||
-- | Display the hledger manual in various formats.
|
-- | Display the hledger manual in various formats.
|
||||||
@ -57,14 +56,14 @@ help' opts _ = do
|
|||||||
[info, man, pager, cat] =
|
[info, man, pager, cat] =
|
||||||
[runInfoForTopic, runManForTopic, runPagerForTopic, printHelpForTopic]
|
[runInfoForTopic, runManForTopic, runPagerForTopic, printHelpForTopic]
|
||||||
viewer
|
viewer
|
||||||
| boolopt "info" $ rawopts_ opts = info
|
| boolopt "help-i" $ rawopts_ opts = info
|
||||||
| boolopt "man" $ rawopts_ opts = man
|
| boolopt "help-m" $ rawopts_ opts = man
|
||||||
| boolopt "pager" $ rawopts_ opts = pager
|
| boolopt "help-p" $ rawopts_ opts = pager
|
||||||
| not interactive = cat
|
| not interactive = cat
|
||||||
| "info" `elem` exes = info
|
| "info" `elem` exes = info
|
||||||
| "man" `elem` exes = man
|
| "man" `elem` exes = man
|
||||||
| pagerprog `elem` exes = pager
|
| pagerprog `elem` exes = pager
|
||||||
| "less" `elem` exes = pager
|
| "less" `elem` exes = pager
|
||||||
| otherwise = cat
|
| otherwise = cat
|
||||||
|
|
||||||
viewer "hledger" mtopic
|
viewer "hledger" mtopic
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user