cli,ui,web: a @FILE argument reads flags & args from FILE, one per line

This commit is contained in:
Simon Michael 2017-09-30 06:29:57 -10:00
parent beb2f5cc8e
commit e5f794d2cb
11 changed files with 463 additions and 436 deletions

View File

@ -155,6 +155,18 @@ m4_define({{_reportingoptions_}}, {{
: convert amounts to their market value on the report end date : convert amounts to their market value on the report end date
(using the most recent applicable [market price](journal.html#market-prices), if any) (using the most recent applicable [market price](journal.html#market-prices), if any)
}} )m4_dnl
m4_dnl
m4_define({{_optionnotes_}}, {{
A @FILE argument will be expanded to the contents of FILE,
which should contain one command line option/argument per line.
When multiple similar reporting options are provided, the last one takes precedence.
Eg `--depth 3 --depth 1` is equivalent to `--depth 1`.
Some of the reporting options can also be written as [query arguments](#queries).
}} )m4_dnl }} )m4_dnl
m4_dnl m4_dnl
m4_define({{_generaloptions_}}, {{ m4_define({{_generaloptions_}}, {{
@ -165,6 +177,8 @@ _reportingoptions_
_helpoptions_ _helpoptions_
_optionnotes_
}} )m4_dnl }} )m4_dnl
m4_dnl m4_dnl
m4_define({{_hledgerdescription_}}, {{ m4_define({{_hledgerdescription_}}, {{

View File

@ -99,7 +99,7 @@ checkUIOpts opts =
getHledgerUIOpts :: IO UIOpts getHledgerUIOpts :: IO UIOpts
--getHledgerUIOpts = processArgs uimode >>= return . decodeRawOpts >>= rawOptsToUIOpts --getHledgerUIOpts = processArgs uimode >>= return . decodeRawOpts >>= rawOptsToUIOpts
getHledgerUIOpts = do getHledgerUIOpts = do
args <- getArgs args <- getArgs >>= expandArgsAt
let args' = replaceNumericFlags args let args' = replaceNumericFlags args
let cmdargopts = either usageError id $ process uimode args' let cmdargopts = either usageError id $ process uimode args'
rawOptsToUIOpts $ decodeRawOpts cmdargopts rawOptsToUIOpts $ decodeRawOpts cmdargopts

View File

@ -81,6 +81,8 @@ hledger help options:
_helpoptions_ _helpoptions_
_optionnotes_
# KEYS # KEYS
`?` shows a help dialog listing all keys. `?` shows a help dialog listing all keys.

View File

@ -95,7 +95,7 @@ checkWebOpts wopts =
getHledgerWebOpts :: IO WebOpts getHledgerWebOpts :: IO WebOpts
--getHledgerWebOpts = processArgs webmode >>= return . decodeRawOpts >>= rawOptsToWebOpts --getHledgerWebOpts = processArgs webmode >>= return . decodeRawOpts >>= rawOptsToWebOpts
getHledgerWebOpts = do getHledgerWebOpts = do
args <- getArgs args <- getArgs >>= expandArgsAt
let args' = replaceNumericFlags args let args' = replaceNumericFlags args
let cmdargopts = either usageError id $ process webmode args' let cmdargopts = either usageError id $ process webmode args'
rawOptsToWebOpts $ decodeRawOpts cmdargopts rawOptsToWebOpts $ decodeRawOpts cmdargopts

View File

@ -136,6 +136,8 @@ hledger help options:
_helpoptions_ _helpoptions_
_optionnotes_
_man_({{ _man_({{
# ENVIRONMENT # ENVIRONMENT

View File

@ -453,7 +453,7 @@ checkCliOpts opts =
-- --
getHledgerCliOpts :: Mode RawOpts -> IO CliOpts getHledgerCliOpts :: Mode RawOpts -> IO CliOpts
getHledgerCliOpts mode' = do getHledgerCliOpts mode' = do
args' <- getArgs args' <- getArgs >>= expandArgsAt
let rawopts = either usageError decodeRawOpts $ process mode' args' let rawopts = either usageError decodeRawOpts $ process mode' args'
opts <- rawOptsToCliOpts rawopts opts <- rawOptsToCliOpts rawopts
debugArgs args' opts debugArgs args' opts

View File

@ -106,7 +106,7 @@ main = do
-- command-line.test. -- command-line.test.
-- some preliminary (imperfect) argument parsing to supplement cmdargs -- some preliminary (imperfect) argument parsing to supplement cmdargs
args <- getArgs args <- getArgs >>= expandArgsAt
let let
args' = moveFlagsAfterCommand $ replaceNumericFlags args args' = moveFlagsAfterCommand $ replaceNumericFlags args
isFlag = ("-" `isPrefixOf`) isFlag = ("-" `isPrefixOf`)

View File

@ -299,11 +299,15 @@ most recent applicable market price, if any)
.RS .RS
.RE .RE
.PP .PP
Note when multiple similar reporting options are provided, the last one A \@FILE argument will be expanded to the contents of FILE, which should
takes precedence. contain one command line option/argument per line.
Eg \f[C]\-p\ feb\ \-p\ mar\f[] is equivalent to \f[C]\-p\ mar\f[].
.PP .PP
Some of these can also be written as queries. When multiple similar reporting options are provided, the last one takes
precedence.
Eg \f[C]\-\-depth\ 3\ \-\-depth\ 1\f[] is equivalent to
\f[C]\-\-depth\ 1\f[].
.PP
Some of the reporting options can also be written as query arguments.
.SS Command options .SS Command options
.PP .PP
To see options for a particular command, including command\-specific To see options for a particular command, including command\-specific

View File

@ -232,10 +232,14 @@ different, like git.)
convert amounts to their market value on the report end date (using convert amounts to their market value on the report end date (using
the most recent applicable market price, if any) the most recent applicable market price, if any)
Note when multiple similar reporting options are provided, the last A @FILE argument will be expanded to the contents of FILE, which
one takes precedence. Eg '-p feb -p mar' is equivalent to '-p mar'. should contain one command line option/argument per line.
Some of these can also be written as queries. When multiple similar reporting options are provided, the last one
takes precedence. Eg '--depth 3 --depth 1' is equivalent to '--depth
1'.
Some of the reporting options can also be written as query arguments.
 
File: hledger.1.info, Node: Command options, Next: Command arguments, Prev: General options, Up: OPTIONS File: hledger.1.info, Node: Command options, Next: Command arguments, Prev: General options, Up: OPTIONS
@ -2199,125 +2203,125 @@ Node: OPTIONS3640
Ref: #options3744 Ref: #options3744
Node: General options4025 Node: General options4025
Ref: #general-options4152 Ref: #general-options4152
Node: Command options6538 Node: Command options6693
Ref: #command-options6691 Ref: #command-options6846
Node: Command arguments7089 Node: Command arguments7244
Ref: #command-arguments7249 Ref: #command-arguments7404
Node: Special characters7370 Node: Special characters7525
Ref: #special-characters7528 Ref: #special-characters7683
Node: Input files8696 Node: Input files8851
Ref: #input-files8834 Ref: #input-files8989
Node: Smart dates10797 Node: Smart dates10952
Ref: #smart-dates10940 Ref: #smart-dates11095
Node: Report start & end date11919 Node: Report start & end date12074
Ref: #report-start-end-date12091 Ref: #report-start-end-date12246
Node: Report intervals13157 Node: Report intervals13312
Ref: #report-intervals13322 Ref: #report-intervals13477
Node: Period expressions13723 Node: Period expressions13878
Ref: #period-expressions13883 Ref: #period-expressions14038
Node: Depth limiting16223 Node: Depth limiting16378
Ref: #depth-limiting16369 Ref: #depth-limiting16524
Node: Pivoting16711 Node: Pivoting16866
Ref: #pivoting16831 Ref: #pivoting16986
Node: Cost18507 Node: Cost18662
Ref: #cost18617 Ref: #cost18772
Node: Market value18735 Node: Market value18890
Ref: #market-value18872 Ref: #market-value19027
Node: Regular expressions20172 Node: Regular expressions20327
Ref: #regular-expressions20310 Ref: #regular-expressions20465
Node: QUERIES21671 Node: QUERIES21826
Ref: #queries21775 Ref: #queries21930
Node: COMMANDS25742 Node: COMMANDS25897
Ref: #commands25856 Ref: #commands26011
Node: accounts26839 Node: accounts26994
Ref: #accounts26939 Ref: #accounts27094
Node: activity27932 Node: activity28087
Ref: #activity28044 Ref: #activity28199
Node: add28403 Node: add28558
Ref: #add28504 Ref: #add28659
Node: balance31162 Node: balance31317
Ref: #balance31275 Ref: #balance31430
Node: Flat mode34432 Node: Flat mode34587
Ref: #flat-mode34559 Ref: #flat-mode34714
Node: Depth limited balance reports34979 Node: Depth limited balance reports35134
Ref: #depth-limited-balance-reports35182 Ref: #depth-limited-balance-reports35337
Node: Multicolumn balance reports35602 Node: Multicolumn balance reports35757
Ref: #multicolumn-balance-reports35813 Ref: #multicolumn-balance-reports35968
Node: Custom balance output40461 Node: Custom balance output40616
Ref: #custom-balance-output40645 Ref: #custom-balance-output40800
Node: Colour support42738 Node: Colour support42893
Ref: #colour-support42899 Ref: #colour-support43054
Node: Output destination43072 Node: Output destination43227
Ref: #output-destination43230 Ref: #output-destination43385
Node: CSV output43500 Node: CSV output43655
Ref: #csv-output43619 Ref: #csv-output43774
Node: balancesheet44016 Node: balancesheet44171
Ref: #balancesheet44154 Ref: #balancesheet44309
Node: balancesheetequity46122 Node: balancesheetequity46277
Ref: #balancesheetequity46273 Ref: #balancesheetequity46428
Node: cashflow47062 Node: cashflow47217
Ref: #cashflow47192 Ref: #cashflow47347
Node: check-dates49104 Node: check-dates49259
Ref: #check-dates49233 Ref: #check-dates49388
Node: check-dupes49350 Node: check-dupes49505
Ref: #check-dupes49477 Ref: #check-dupes49632
Node: equity49614 Node: equity49769
Ref: #equity49726 Ref: #equity49881
Node: help49889 Node: help50044
Ref: #help49992 Ref: #help50147
Node: import51066 Node: import51221
Ref: #import51182 Ref: #import51337
Node: incomestatement51577 Node: incomestatement51732
Ref: #incomestatement51713 Ref: #incomestatement51868
Node: prices53666 Node: prices53821
Ref: #prices53783 Ref: #prices53938
Node: print53826 Node: print53981
Ref: #print53938 Ref: #print54093
Node: print-unique58784 Node: print-unique58939
Ref: #print-unique58912 Ref: #print-unique59067
Node: register58980 Node: register59135
Ref: #register59109 Ref: #register59264
Node: Custom register output63610 Node: Custom register output63765
Ref: #custom-register-output63741 Ref: #custom-register-output63896
Node: register-match65038 Node: register-match65193
Ref: #register-match65174 Ref: #register-match65329
Node: rewrite65357 Node: rewrite65512
Ref: #rewrite65476 Ref: #rewrite65631
Node: stats65545 Node: stats65700
Ref: #stats65650 Ref: #stats65805
Node: tags66531 Node: tags66686
Ref: #tags66631 Ref: #tags66786
Node: test66663 Node: test66818
Ref: #test66749 Ref: #test66904
Node: ADD-ON COMMANDS67117 Node: ADD-ON COMMANDS67272
Ref: #add-on-commands67229 Ref: #add-on-commands67384
Node: Official add-ons68516 Node: Official add-ons68671
Ref: #official-add-ons68658 Ref: #official-add-ons68813
Node: api68745 Node: api68900
Ref: #api68836 Ref: #api68991
Node: ui68888 Node: ui69043
Ref: #ui68989 Ref: #ui69144
Node: web69047 Node: web69202
Ref: #web69138 Ref: #web69293
Node: Third party add-ons69184 Node: Third party add-ons69339
Ref: #third-party-add-ons69361 Ref: #third-party-add-ons69516
Node: diff69496 Node: diff69651
Ref: #diff69595 Ref: #diff69750
Node: iadd69694 Node: iadd69849
Ref: #iadd69810 Ref: #iadd69965
Node: interest69893 Node: interest70048
Ref: #interest70016 Ref: #interest70171
Node: irr70111 Node: irr70266
Ref: #irr70211 Ref: #irr70366
Node: Experimental add-ons70289 Node: Experimental add-ons70444
Ref: #experimental-add-ons70443 Ref: #experimental-add-ons70598
Node: autosync70734 Node: autosync70889
Ref: #autosync70848 Ref: #autosync71003
Node: budget71087 Node: budget71242
Ref: #budget71211 Ref: #budget71366
Node: chart71277 Node: chart71432
Ref: #chart71396 Ref: #chart71551
Node: check71467 Node: check71622
Ref: #check71571 Ref: #check71726
 
End Tag Table End Tag Table

File diff suppressed because it is too large Load Diff

View File

@ -18,10 +18,7 @@ General reporting options:
_reportingoptions_ _reportingoptions_
Note when multiple similar reporting options are provided, the last one takes precedence. _optionnotes_
Eg `-p feb -p mar` is equivalent to `-p mar`.
Some of these can also be written as [queries](#queries).
## Command options ## Command options