help: show only the hledger manual, for now
This commit is contained in:
parent
7d3f05b16a
commit
f20cd2b112
@ -19,10 +19,7 @@ module Hledger.Cli.Commands.Help (
|
|||||||
|
|
||||||
import Prelude ()
|
import Prelude ()
|
||||||
import "base-compat-batteries" Prelude.Compat
|
import "base-compat-batteries" Prelude.Compat
|
||||||
import Data.Char
|
|
||||||
import Data.List
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Safe
|
|
||||||
import System.Console.CmdArgs.Explicit
|
import System.Console.CmdArgs.Explicit
|
||||||
import System.Environment
|
import System.Environment
|
||||||
import System.IO
|
import System.IO
|
||||||
@ -43,9 +40,9 @@ helpmode = hledgerCommandMode
|
|||||||
]
|
]
|
||||||
[]
|
[]
|
||||||
[]
|
[]
|
||||||
([], Just $ argsFlag "[MANUAL]")
|
([], Nothing) -- Just $ argsFlag "[TOPIC]"
|
||||||
|
|
||||||
-- | List or display one of the hledger manuals in various formats.
|
-- | Display the hledger manual in various formats.
|
||||||
-- You can select a docs viewer with one of the `--info`, `--man`, `--pager` flags.
|
-- You can select a docs viewer with one of the `--info`, `--man`, `--pager` flags.
|
||||||
-- Otherwise it will use the first available of: info, man, $PAGER, less, stdout
|
-- Otherwise it will use the first available of: info, man, $PAGER, less, stdout
|
||||||
-- (and always stdout if output is non-interactive).
|
-- (and always stdout if output is non-interactive).
|
||||||
@ -55,10 +52,10 @@ help' opts _ = do
|
|||||||
pagerprog <- fromMaybe "less" <$> lookupEnv "PAGER"
|
pagerprog <- fromMaybe "less" <$> lookupEnv "PAGER"
|
||||||
interactive <- hIsTerminalDevice stdout
|
interactive <- hIsTerminalDevice stdout
|
||||||
let
|
let
|
||||||
args = take 1 $ listofstringopt "args" $ rawopts_ opts
|
-- args = take 1 $ listofstringopt "args" $ rawopts_ opts
|
||||||
topic = case args of
|
-- topic = case args of
|
||||||
[pat] -> headMay [t | t <- docTopics, map toLower pat `isInfixOf` t]
|
-- [pat] -> headMay [t | t <- docTopics, map toLower pat `isInfixOf` t]
|
||||||
_ -> Nothing
|
-- _ -> Nothing
|
||||||
[info, man, pager, cat] =
|
[info, man, pager, cat] =
|
||||||
[runInfoForTopic, runManForTopic, runPagerForTopic pagerprog, printHelpForTopic]
|
[runInfoForTopic, runManForTopic, runPagerForTopic pagerprog, printHelpForTopic]
|
||||||
viewer
|
viewer
|
||||||
@ -70,11 +67,12 @@ help' opts _ = do
|
|||||||
| "man" `elem` exes = man
|
| "man" `elem` exes = man
|
||||||
| pagerprog `elem` exes = pager
|
| pagerprog `elem` exes = pager
|
||||||
| otherwise = cat
|
| otherwise = cat
|
||||||
case topic of
|
viewer "hledger"
|
||||||
Nothing -> putStrLn $ unlines [
|
-- case topic of
|
||||||
"Please choose a manual by typing \"hledger help MANUAL\" (any substring is ok)."
|
-- Nothing -> putStrLn $ unlines [
|
||||||
,"A viewer (info, man, $PAGER, or stdout) will be auto-selected,"
|
-- "Please choose a manual by typing \"hledger help MANUAL\" (any substring is ok)."
|
||||||
,"or type \"hledger help -h\" to see options. Manuals available:"
|
-- ,"A viewer (info, man, $PAGER, or stdout) will be auto-selected,"
|
||||||
]
|
-- ,"or type \"hledger help -h\" to see options. Manuals available:"
|
||||||
++ "\n " ++ unwords docTopics
|
-- ]
|
||||||
Just t -> viewer t
|
-- ++ "\n " ++ unwords docTopics
|
||||||
|
-- Just t -> viewer t
|
||||||
|
|||||||
@ -1,40 +1,16 @@
|
|||||||
help\
|
help\
|
||||||
Show any of the hledger manuals.
|
Show the hledger user manual in one of several formats.
|
||||||
|
|
||||||
_FLAGS
|
_FLAGS
|
||||||
|
|
||||||
The `help` command displays any of the main [hledger user manuals](https://hledger.org/index.html),
|
This command shows the user manual built in to this hledger version,
|
||||||
in one of several ways.
|
using the best viewer it can find.
|
||||||
Run it with no argument to list the manuals, or provide a full or partial manual name to select one.
|
It can be useful if the correct version of the hledger manual,
|
||||||
|
or the usual viewing tools, are not installed on your system.
|
||||||
|
|
||||||
hledger manuals are available in several formats.
|
It will use the first of these viewers that it finds in $PATH:
|
||||||
hledger help will use the first of these display methods that it finds:
|
`info`, `man`, $PAGER, `less`, or stdout.
|
||||||
info, man, $PAGER, less, stdout (or when non-interactive, just stdout).
|
When run non-interactively, it always uses stdout.
|
||||||
You can force a particular viewer with the `--info/-i`, `--man/-m`,
|
Or you can force a particular viewer with the
|
||||||
`--pager/-p` flags.
|
`--info/-i`, `--man/-m`, or `--pager/-p` flags.
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ hledger help
|
|
||||||
Please choose a manual by typing "hledger help MANUAL" (a substring is ok).
|
|
||||||
Manuals: hledger hledger-ui hledger-web
|
|
||||||
```
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ hledger help h --man
|
|
||||||
|
|
||||||
hledger(1) hledger User Manuals hledger(1)
|
|
||||||
|
|
||||||
NAME
|
|
||||||
hledger - a command-line accounting tool
|
|
||||||
|
|
||||||
SYNOPSIS
|
|
||||||
hledger [-f FILE] COMMAND [OPTIONS] [ARGS]
|
|
||||||
hledger [-f FILE] ADDONCMD -- [OPTIONS] [ARGS]
|
|
||||||
hledger
|
|
||||||
|
|
||||||
DESCRIPTION
|
|
||||||
hledger is a cross-platform program for tracking money, time, or any
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user