mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-19 10:17:35 +03:00
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:
parent
36246e4976
commit
c8246e7323
1
Makefile
1
Makefile
@ -582,6 +582,7 @@ SHAKEDEPS= \
|
|||||||
--package base-prelude \
|
--package base-prelude \
|
||||||
--package directory \
|
--package directory \
|
||||||
--package extra \
|
--package extra \
|
||||||
|
--package process \
|
||||||
--package safe \
|
--package safe \
|
||||||
--package shake \
|
--package shake \
|
||||||
--package time \
|
--package time \
|
||||||
|
19
Shake.hs
19
Shake.hs
@ -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
|
It requires stack (https://haskell-lang.org/get-started) and
|
||||||
auto-installs the packages above. Also, some rules require:
|
auto-installs the packages above. Also, some rules require:
|
||||||
|
|
||||||
|
- GNU sed
|
||||||
- groff
|
- groff
|
||||||
- m4
|
- m4
|
||||||
- makeinfo
|
- makeinfo
|
||||||
@ -43,8 +44,10 @@ not having to write :: Action ExitCode after a non-final cmd
|
|||||||
|
|
||||||
import Prelude ()
|
import Prelude ()
|
||||||
import "base-prelude" BasePrelude
|
import "base-prelude" BasePrelude
|
||||||
|
-- keep imports synced with Makefile -> SHAKEDEPS
|
||||||
import "directory" System.Directory as S (getDirectoryContents)
|
import "directory" System.Directory as S (getDirectoryContents)
|
||||||
import "extra" Data.List.Extra
|
import "extra" Data.List.Extra
|
||||||
|
import "process" System.Process
|
||||||
import "safe" Safe
|
import "safe" Safe
|
||||||
import "shake" Development.Shake
|
import "shake" Development.Shake
|
||||||
import "shake" Development.Shake.FilePath
|
import "shake" Development.Shake.FilePath
|
||||||
@ -56,6 +59,7 @@ usage = unlines
|
|||||||
,"./Shake.hs # compile this script"
|
,"./Shake.hs # compile this script"
|
||||||
,"./Shake manuals # generate the txt/man/info manuals"
|
,"./Shake manuals # generate the txt/man/info manuals"
|
||||||
,"./Shake website # generate the website and web 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 PKG # build the specified hledger package, with awareness of embedded docs"
|
||||||
,"./Shake build # build all hledger packages, with awareness of embedded docs"
|
,"./Shake build # build all hledger packages, with awareness of embedded docs"
|
||||||
,"./Shake all # generate everything"
|
,"./Shake all # generate everything"
|
||||||
@ -82,6 +86,10 @@ towebmd = "-t markdown-smart-fenced_divs --atx-headers"
|
|||||||
|
|
||||||
main = do
|
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:
|
-- hledger manual also includes the markdown files from here:
|
||||||
let commandsdir = "hledger/Hledger/Cli/Commands"
|
let commandsdir = "hledger/Hledger/Cli/Commands"
|
||||||
commandmds <- filter (".md" `isSuffixOf`) . map (commandsdir </>) <$> S.getDirectoryContents commandsdir
|
commandmds <- filter (".md" `isSuffixOf`) . map (commandsdir </>) <$> S.getDirectoryContents commandsdir
|
||||||
@ -97,7 +105,7 @@ main = do
|
|||||||
|
|
||||||
phony "help" $ liftIO $ putStrLn usage
|
phony "help" $ liftIO $ putStrLn usage
|
||||||
|
|
||||||
phony "all" $ need ["manuals", "website", "build"]
|
phony "all" $ need ["commandhelp", "manuals", "build", "website"]
|
||||||
|
|
||||||
-- phony "compile" $ need ["Shake"]
|
-- phony "compile" $ need ["Shake"]
|
||||||
-- "Shake" %> \out -> do
|
-- "Shake" %> \out -> do
|
||||||
@ -159,7 +167,7 @@ main = do
|
|||||||
-- manuals rendered to info, ready for info (hledger/hledger.info)
|
-- manuals rendered to info, ready for info (hledger/hledger.info)
|
||||||
infomanuals = [manualDir m </> m <.> "info" | m <- manualNames]
|
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]
|
webmanuals = ["site" </> manpageNameToUri m <.> "md" | m <- manpageNames]
|
||||||
|
|
||||||
-- website html pages - all manual versions plus misc pages in site/ or copied from elsewhere.
|
-- 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
|
cmd Shell "stack build " pkg
|
||||||
| pkg <- packages ]
|
| pkg <- packages ]
|
||||||
|
|
||||||
|
phony "commandhelp" $ need commandtxts
|
||||||
|
|
||||||
commandtxts |%> \out -> do
|
commandtxts |%> \out -> do
|
||||||
let src = out -<.> "md"
|
let src = out -<.> "md"
|
||||||
-- lib = "doc/lib.m4"
|
-- lib = "doc/lib.m4"
|
||||||
need [src]
|
need [src]
|
||||||
cmd Shell
|
cmd Shell
|
||||||
-- "m4 -P -DHELP -I" commandsdir lib src "|"
|
-- "m4 -P -DHELP -I" commandsdir lib src "|"
|
||||||
pandoc fromsrcmd src "-t plain" "-o" out
|
pandoc fromsrcmd src "-t plain"
|
||||||
|
"|" sed "-e" ["'s/^ //'"]
|
||||||
|
">" out
|
||||||
|
|
||||||
-- MISC
|
-- MISC
|
||||||
|
|
||||||
@ -387,6 +399,7 @@ main = do
|
|||||||
|
|
||||||
phony "clean" $ do
|
phony "clean" $ do
|
||||||
putNormal "Cleaning generated files"
|
putNormal "Cleaning generated files"
|
||||||
|
removeFilesAfter "." commandtxts
|
||||||
removeFilesAfter "." webmanuals
|
removeFilesAfter "." webmanuals
|
||||||
removeFilesAfter "." [webmancombined]
|
removeFilesAfter "." [webmancombined]
|
||||||
removeFilesAfter "." ["site/README.md", "site/CONTRIBUTING.md"]
|
removeFilesAfter "." ["site/README.md", "site/CONTRIBUTING.md"]
|
||||||
|
@ -189,6 +189,7 @@ Help:
|
|||||||
help [MANUAL] show hledger manuals in various formats
|
help [MANUAL] show hledger manuals in various formats
|
||||||
|
|
||||||
|]
|
|]
|
||||||
|
-- commands show brief commands list
|
||||||
-- edit open a text editor on some part of the journal
|
-- edit open a text editor on some part of the journal
|
||||||
-- aregister (ar, areg) show transactions in a single account
|
-- aregister (ar, areg) show transactions in a single account
|
||||||
|
|
||||||
|
@ -59,3 +59,4 @@ Saved.
|
|||||||
Starting the next transaction (. or ctrl-D/ctrl-C to quit)
|
Starting the next transaction (. or ctrl-D/ctrl-C to quit)
|
||||||
Date [2015/05/22]: <CTRL-D> $
|
Date [2015/05/22]: <CTRL-D> $
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ or by using the `--width`/`-w` option.
|
|||||||
The description and account columns normally share the space equally
|
The description and account columns normally share the space equally
|
||||||
(about half of (width - 40) each). You can adjust this by adding a
|
(about half of (width - 40) each). You can adjust this by adding a
|
||||||
description width as part of --width's argument, comma-separated:
|
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) ---------------------------------->
|
<--------------------------------- width (W) ---------------------------------->
|
||||||
date (10) description (D) account (W-41-D) amount (12) balance (12)
|
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
|
$ COLUMNS=100 hledger reg # set with one-time environment variable
|
||||||
$ export COLUMNS=100; hledger reg # set till session end (or window resize)
|
$ 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 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
|
This command also supports
|
||||||
|
@ -81,7 +81,7 @@ bash shell variable) or by using the --width/-w option.
|
|||||||
The description and account columns normally share the space equally
|
The description and account columns normally share the space equally
|
||||||
(about half of (width - 40) each). You can adjust this by adding a
|
(about half of (width - 40) each). You can adjust this by adding a
|
||||||
description width as part of --width's argument, comma-separated:
|
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) ---------------------------------->
|
<--------------------------------- width (W) ---------------------------------->
|
||||||
date (10) description (D) account (W-41-D) amount (12) balance (12)
|
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
|
$ COLUMNS=100 hledger reg # set with one-time environment variable
|
||||||
$ export COLUMNS=100; hledger reg # set till session end (or window resize)
|
$ 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 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
|
This command also supports output destination and output format
|
||||||
selection.
|
selection.
|
||||||
|
Loading…
Reference in New Issue
Block a user