diff --git a/doc/tldr/hledger-import.md b/doc/tldr/hledger-import.md index d1d7a82ce..f6ec991b4 100644 --- a/doc/tldr/hledger-import.md +++ b/doc/tldr/hledger-import.md @@ -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`: diff --git a/hledger-lib/Hledger/Read/Common.hs b/hledger-lib/Hledger/Read/Common.hs index a8fb1d2d2..c454fe347 100644 --- a/hledger-lib/Hledger/Read/Common.hs +++ b/hledger-lib/Hledger/Read/Common.hs @@ -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 diff --git a/hledger-lib/Hledger/Read/RulesReader.hs b/hledger-lib/Hledger/Read/RulesReader.hs index 9ea09e736..5181ec7a8 100644 --- a/hledger-lib/Hledger/Read/RulesReader.hs +++ b/hledger-lib/Hledger/Read/RulesReader.hs @@ -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 diff --git a/hledger-ui/Hledger/UI/UIOptions.hs b/hledger-ui/Hledger/UI/UIOptions.hs index 7266c371b..05c37a177 100644 --- a/hledger-ui/Hledger/UI/UIOptions.hs +++ b/hledger-ui/Hledger/UI/UIOptions.hs @@ -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" diff --git a/hledger/Hledger/Cli.hs b/hledger/Hledger/Cli.hs index 6ab8edc14..3ebfd3597 100644 --- a/hledger/Hledger/Cli.hs +++ b/hledger/Hledger/Cli.hs @@ -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 = [] diff --git a/hledger/Hledger/Cli/CliOptions.hs b/hledger/Hledger/Cli/CliOptions.hs index 75f491e90..f276439bf 100644 --- a/hledger/Hledger/Cli/CliOptions.hs +++ b/hledger/Hledger/Cli/CliOptions.hs @@ -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... diff --git a/hledger/hledger.m4.md b/hledger/hledger.m4.md index 7717f9b02..1fb15098c 100644 --- a/hledger/hledger.m4.md +++ b/hledger/hledger.m4.md @@ -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 diff --git a/hledger/test/cli/cli.test b/hledger/test/cli/cli.test index 12b815ae0..5fa7399d8 100644 --- a/hledger/test/cli/cli.test +++ b/hledger/test/cli/cli.test @@ -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 diff --git a/hledger/test/errors/README.md b/hledger/test/errors/README.md index 8d7272f99..4df0f3c78 100644 --- a/hledger/test/errors/README.md +++ b/hledger/test/errors/README.md @@ -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 ``` diff --git a/hledger/test/errors/csvstdinrules.test b/hledger/test/errors/csvstdinrules.test index bb598c777..81a3371eb 100644 --- a/hledger/test/errors/csvstdinrules.test +++ b/hledger/test/errors/csvstdinrules.test @@ -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 diff --git a/hledger/test/import/match.test b/hledger/test/import/match.test index 728c9b982..5be198609 100644 --- a/hledger/test/import/match.test +++ b/hledger/test/import/match.test @@ -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