mirror of
https://github.com/simonmichael/hledger.git
synced 2024-10-06 10:57:30 +03:00
imp: cli: rename --rules-file to --rules; tweak options help
For brevity, and consistency with --conf. --rules-file remains supported, as a hidden option. hledger's main mode now supports the hidden legacy flags, as the command modes do.
This commit is contained in:
parent
5739bff249
commit
40620666f8
@ -13,7 +13,7 @@
|
||||
|
||||
- Import new transactions from all CSV files, using the same rules for all:
|
||||
|
||||
`hledger import --rules-file {{common.rules}} *.csv`
|
||||
`hledger import --rules {{common.rules}} *.csv`
|
||||
|
||||
- Show conversion errors or results while editing `bank.csv.rules`:
|
||||
|
||||
|
@ -209,7 +209,7 @@ rawOptsToInputOpts day rawopts =
|
||||
in definputopts{
|
||||
-- files_ = listofstringopt "file" rawopts
|
||||
mformat_ = Nothing
|
||||
,mrules_file_ = maybestringopt "rules-file" rawopts
|
||||
,mrules_file_ = maybestringopt "rules" rawopts
|
||||
,aliases_ = listofstringopt "alias" rawopts
|
||||
,anon_ = boolopt "obfuscate" rawopts
|
||||
,new_ = boolopt "new" rawopts
|
||||
|
@ -112,7 +112,7 @@ getDownloadDir = do
|
||||
-- file's directory. When a glob pattern matches multiple files, the alphabetically
|
||||
-- last is used. (Eg in case of multiple numbered downloads, the highest-numbered
|
||||
-- will be used.)
|
||||
-- The provided text, or a --rules-file option, are ignored by this reader.
|
||||
-- The provided text, or a --rules option, are ignored by this reader.
|
||||
-- Balance assertions are not checked.
|
||||
parse :: InputOpts -> FilePath -> Text -> ExceptT String IO Journal
|
||||
parse iopts f _ = do
|
||||
@ -883,7 +883,7 @@ _CSV_READING__________________________________________ = undefined
|
||||
-- 4. Return the transactions as a Journal.
|
||||
--
|
||||
readJournalFromCsv :: Maybe (Either CsvRules FilePath) -> FilePath -> Text -> Maybe SepFormat -> ExceptT String IO Journal
|
||||
readJournalFromCsv Nothing "-" _ _ = throwError "please use --rules-file when reading CSV from stdin"
|
||||
readJournalFromCsv Nothing "-" _ _ = throwError "please use --rules when reading CSV from stdin"
|
||||
readJournalFromCsv merulesfile csvfile csvtext sep = do
|
||||
-- for now, correctness is the priority here, efficiency not so much
|
||||
|
||||
|
@ -47,7 +47,6 @@ prognameandversion =
|
||||
|
||||
|
||||
uiflags = [
|
||||
-- flagNone ["debug-ui"] (setboolopt "rules-file") "run with no terminal output, showing console"
|
||||
flagNone ["watch","w"] (setboolopt "watch") "watch for data and date changes and reload automatically"
|
||||
,flagReq ["theme"] (\s opts -> Right $ setopt "theme" s opts) "THEME" ("use this custom display theme ("++intercalate ", " themeNames++")")
|
||||
,flagNone ["cash"] (setboolopt "cash") "start in the cash accounts screen"
|
||||
|
@ -141,7 +141,8 @@ mainmode addons = defMode {
|
||||
]
|
||||
-- flags handled but not shown in the help:
|
||||
,groupHidden =
|
||||
[detailedversionflag]
|
||||
detailedversionflag :
|
||||
hiddenflags
|
||||
-- ++ inputflags -- included here so they'll not raise a confusing error if present with no COMMAND
|
||||
}
|
||||
,modeHelpSuffix = []
|
||||
|
@ -143,7 +143,7 @@ prognameandversion =
|
||||
-- common cmdargs flags
|
||||
-- keep synced with flag docs in doc/common.m4
|
||||
|
||||
-- | Common input-related flags: --file, --rules-file, --alias...
|
||||
-- | Common input-related flags: --file, --rules, --conf, --alias...
|
||||
inputflags :: [Flag RawOpts]
|
||||
inputflags = [
|
||||
flagReq ["file","f"] (\s opts -> Right $ setopt "file" s opts) "[FMT:]FILE" "Read data from FILE, or from stdin if FILE is -, inferring format from extension or a FMT: prefix. Can be specified more than once. If not specified, reads from $LEDGER_FILE or $HOME/.hledger.journal."
|
||||
@ -275,6 +275,7 @@ hiddenflags = [
|
||||
,flagNone ["pretty-tables"] (setopt "pretty" "always") "legacy flag that was renamed"
|
||||
,flagNone ["anon"] (setboolopt "anon") "deprecated, renamed to --obfuscate" -- #2133, handled by anonymiseByOpts
|
||||
,flagNone ["obfuscate"] (setboolopt "obfuscate") "slightly obfuscate hledger's output. Warning, does not give privacy. Formerly --anon." -- #2133, handled by maybeObfuscate
|
||||
,flagReq ["rules-file"] (\s opts -> Right $ setopt "rules" s opts) "RULESFILE" "was renamed to --rules"
|
||||
]
|
||||
|
||||
-- | Common output-related flags: --output-file, --output-format...
|
||||
|
@ -2908,7 +2908,7 @@ attributes.
|
||||
By default, hledger expects this rules file to be named like the CSV file,
|
||||
with an extra `.rules` extension added, in the same directory.
|
||||
Eg when asked to read `foo/FILE.csv`, hledger looks for `foo/FILE.csv.rules`.
|
||||
You can specify a different rules file with the `--rules-file` option.
|
||||
You can specify a different rules file with the `--rules` option.
|
||||
|
||||
At minimum, the rules file must identify the date and amount fields,
|
||||
and often it also specifies the date format and how many header lines
|
||||
@ -3634,9 +3634,8 @@ $ cat foo.dat | hledger -f ssv:- print
|
||||
### Reading multiple CSV files
|
||||
|
||||
If you use multiple `-f` options to read multiple CSV files at once,
|
||||
hledger will look for a correspondingly-named rules file for each CSV
|
||||
file. But if you use the `--rules-file` option, that rules file will
|
||||
be used for all the CSV files.
|
||||
hledger will look for a correspondingly-named rules file for each CSV file.
|
||||
But if you specify a rules file with `--rules`, that rules file will be used for all the CSV files.
|
||||
|
||||
### Reading files specified by rule
|
||||
|
||||
|
@ -48,8 +48,8 @@
|
||||
# - an unrecognised command shows an error and gives non-zero exit status
|
||||
#
|
||||
# - usually the command must come first, followed by options and arguments in any order
|
||||
# - a few options may also go before the command: -f, --rules-file, --alias, --help, --version, --debug.
|
||||
# - option flags may be written in full or as a unique prefix, eg --rules for --rules-file
|
||||
# - a few options may also go before the command: -f, --rules, --alias, --help, --version, --debug.
|
||||
# - option flags may be written in full or as a unique prefix
|
||||
# - if the command is external, options and arguments after the command are handled by that executable, not hledger
|
||||
#
|
||||
# - the --help flag has highest priority
|
||||
|
@ -523,7 +523,7 @@ expecting '!', '*', or end of input
|
||||
|
||||
### csvstdinrules
|
||||
```
|
||||
hledger: Error: please use --rules-file when reading CSV from stdin
|
||||
hledger: Error: please use --rules when reading CSV from stdin
|
||||
```
|
||||
|
||||
|
||||
@ -535,6 +535,6 @@ hledger: Error: CSV record ["b"] has less than two fields
|
||||
|
||||
### csvstdinrules
|
||||
```
|
||||
hledger: Error: please use --rules-file when reading CSV from stdin
|
||||
hledger: Error: please use --rules when reading CSV from stdin
|
||||
```
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
$$$ sh csvstdinrules.sh
|
||||
>>>2 /hledger: Error: please use --rules-file when reading CSV from stdin
|
||||
>>>2 /hledger: Error: please use --rules when reading CSV from stdin
|
||||
/
|
||||
>>>= 1
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Various match group interpolation tests. See the comments
|
||||
# in match.rules for specifics.
|
||||
$ hledger -f a.j import --rules-file match.rules --dry-run match.csv
|
||||
$ hledger -f a.j import --rules match.rules --dry-run match.csv
|
||||
; would import 1 new transactions from match.csv:
|
||||
|
||||
2022-12-15 Zettle_*Robert W. Bell
|
||||
|
Loading…
Reference in New Issue
Block a user