cli: command help: reduce width, line wrapping

cmdargs wraps any lines longer than 78 characters.  To (mostly) avoid
this, we now display verbatim blocks unindented, and some of
register's examples have been altered to make them fit.
This commit is contained in:
Simon Michael 2019-01-30 17:55:56 -08:00
parent 36246e4976
commit c8246e7323
21 changed files with 526 additions and 510 deletions

View File

@ -582,6 +582,7 @@ SHAKEDEPS= \
--package base-prelude \
--package directory \
--package extra \
--package process \
--package safe \
--package shake \
--package time \

View File

@ -20,6 +20,7 @@ compiling is recommended; run the script in interpreted mode to do that.
It requires stack (https://haskell-lang.org/get-started) and
auto-installs the packages above. Also, some rules require:
- GNU sed
- groff
- m4
- makeinfo
@ -43,8 +44,10 @@ not having to write :: Action ExitCode after a non-final cmd
import Prelude ()
import "base-prelude" BasePrelude
-- keep imports synced with Makefile -> SHAKEDEPS
import "directory" System.Directory as S (getDirectoryContents)
import "extra" Data.List.Extra
import "process" System.Process
import "safe" Safe
import "shake" Development.Shake
import "shake" Development.Shake.FilePath
@ -56,6 +59,7 @@ usage = unlines
,"./Shake.hs # compile this script"
,"./Shake manuals # generate the txt/man/info manuals"
,"./Shake website # generate the website and web manuals"
,"./Shake commandhelp # generate the help text for hledger commands"
,"./Shake PKG # build the specified hledger package, with awareness of embedded docs"
,"./Shake build # build all hledger packages, with awareness of embedded docs"
,"./Shake all # generate everything"
@ -82,6 +86,10 @@ towebmd = "-t markdown-smart-fenced_divs --atx-headers"
main = do
-- try to ensure we have a modern sed
sed' <- readCreateProcess (shell "which gsed || which sed") ""
let sed = sed' ++ " -E"
-- hledger manual also includes the markdown files from here:
let commandsdir = "hledger/Hledger/Cli/Commands"
commandmds <- filter (".md" `isSuffixOf`) . map (commandsdir </>) <$> S.getDirectoryContents commandsdir
@ -97,7 +105,7 @@ main = do
phony "help" $ liftIO $ putStrLn usage
phony "all" $ need ["manuals", "website", "build"]
phony "all" $ need ["commandhelp", "manuals", "build", "website"]
-- phony "compile" $ need ["Shake"]
-- "Shake" %> \out -> do
@ -159,7 +167,7 @@ main = do
-- manuals rendered to info, ready for info (hledger/hledger.info)
infomanuals = [manualDir m </> m <.> "info" | m <- manualNames]
-- manuals rendered to markdown, ready for conversion to html (site/hledger.md)
-- individual manuals rendered to markdown, ready for conversion to html (site/hledger.md)
webmanuals = ["site" </> manpageNameToUri m <.> "md" | m <- manpageNames]
-- website html pages - all manual versions plus misc pages in site/ or copied from elsewhere.
@ -362,13 +370,17 @@ main = do
cmd Shell "stack build " pkg
| pkg <- packages ]
phony "commandhelp" $ need commandtxts
commandtxts |%> \out -> do
let src = out -<.> "md"
-- lib = "doc/lib.m4"
need [src]
cmd Shell
-- "m4 -P -DHELP -I" commandsdir lib src "|"
pandoc fromsrcmd src "-t plain" "-o" out
pandoc fromsrcmd src "-t plain"
"|" sed "-e" ["'s/^ //'"]
">" out
-- MISC
@ -387,6 +399,7 @@ main = do
phony "clean" $ do
putNormal "Cleaning generated files"
removeFilesAfter "." commandtxts
removeFilesAfter "." webmanuals
removeFilesAfter "." [webmancombined]
removeFilesAfter "." ["site/README.md", "site/CONTRIBUTING.md"]

View File

@ -189,6 +189,7 @@ Help:
help [MANUAL] show hledger manuals in various formats
|]
-- commands show brief commands list
-- edit open a text editor on some part of the journal
-- aregister (ar, areg) show transactions in a single account

View File

@ -59,3 +59,4 @@ Saved.
Starting the next transaction (. or ctrl-D/ctrl-C to quit)
Date [2015/05/22]: <CTRL-D> $
```

View File

@ -91,7 +91,7 @@ or by using the `--width`/`-w` option.
The description and account columns normally share the space equally
(about half of (width - 40) each). You can adjust this by adding a
description width as part of --width's argument, comma-separated:
`--width W,D` . Here's a diagram:
`--width W,D` . Here's a diagram (won't display correctly in --help):
```
<--------------------------------- width (W) ---------------------------------->
date (10) description (D) account (W-41-D) amount (12) balance (12)
@ -104,7 +104,7 @@ $ hledger reg -w 100 # use width 100
$ COLUMNS=100 hledger reg # set with one-time environment variable
$ export COLUMNS=100; hledger reg # set till session end (or window resize)
$ hledger reg -w 100,40 # set overall width 100, description width 40
$ hledger reg -w $COLUMNS,40 # use terminal width, and set description width
$ hledger reg -w $COLUMNS,40 # use terminal width, & description width 40
```
This command also supports

View File

@ -81,7 +81,7 @@ bash shell variable) or by using the --width/-w option.
The description and account columns normally share the space equally
(about half of (width - 40) each). You can adjust this by adding a
description width as part of --width's argument, comma-separated:
--width W,D . Here's a diagram:
--width W,D . Here's a diagram (won't display correctly in --help):
<--------------------------------- width (W) ---------------------------------->
date (10) description (D) account (W-41-D) amount (12) balance (12)
@ -94,7 +94,7 @@ and some examples:
$ COLUMNS=100 hledger reg # set with one-time environment variable
$ export COLUMNS=100; hledger reg # set till session end (or window resize)
$ hledger reg -w 100,40 # set overall width 100, description width 40
$ hledger reg -w $COLUMNS,40 # use terminal width, and set description width
$ hledger reg -w $COLUMNS,40 # use terminal width, & description width 40
This command also supports output destination and output format
selection.