imp:cli: clearer help for -f, and the add and import commands

From euouae's irc feedback
This commit is contained in:
Simon Michael 2025-08-24 08:59:50 +01:00
parent 03262f3fff
commit 4c1c44ce36
4 changed files with 12 additions and 5 deletions

View File

@ -154,7 +154,14 @@ Right binaryinfo = parseHledgerVersion prognameandversion
-- | 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."
flagReq ["file","f"] (\s opts -> Right $ setopt "file" s opts) "[FMT:]FILE" $ unwords [
"Use this as the journal file (- means stdin)."
,"If not specified, $LEDGER_FILE or ~/.hledger.journal will be used."
,"If specified more than once, the files will be read in order."
,"Each file's format (journal, csv, timeclock, timedot, rules..) is inferred from the file extension or a FMT: prefix."
,"Some commands (add, import) write to the (first) file,"
,"and expect it to be in journal format."
]
,flagReq ["rules"] (\s opts -> Right $ setopt "rules" s opts) "RULESFILE" "Use rules defined in this rules file for converting subsequent CSV/SSV/TSV files. If not specified, uses FILE.csv.rules for each FILE.csv." -- see also hiddenflags
,flagReq ["alias"] (\s opts -> Right $ setopt "alias" s opts) "A=B|/RGX/=RPL" "transform account names from A to B, or by replacing regular expression matches"

View File

@ -54,7 +54,7 @@ addmode = hledgerCommandMode
[flagNone ["no-new-accounts"] (setboolopt "no-new-accounts") "don't allow creating new accounts"]
[generalflagsgroup2]
[]
([], Just $ argsFlag "[DATE [DESCRIPTION [ACCOUNT1 [AMOUNT1 [ACCOUNT2 [ETC...]]]]]]")
([], Just $ argsFlag "[-f JOURNALFILE] [DATE [DESCRIPTION [ACCOUNT1 [ETC..]]]]]")
-- | State used while entering transactions.
data EntryState = EntryState {

View File

@ -1,6 +1,6 @@
## add
Add new transactions to a journal file, with interactive prompting in the console.
Add new transactions to a journal file, with interactive prompting.
```flags
Flags:

View File

@ -27,7 +27,7 @@ importmode = hledgerCommandMode
]
cligeneralflagsgroups1
hiddenflags
([], Just $ argsFlag "FILE [...]")
([], Just $ argsFlag "[-f JOURNALFILE] DATAFILES...")
importcmd opts@CliOpts{rawopts_=rawopts,inputopts_=iopts} j = do
-- XXX could be helpful to show the last-seen date, and number of old transactions, too
@ -53,7 +53,7 @@ importcmd opts@CliOpts{rawopts_=rawopts,inputopts_=iopts} j = do
}
case inputfiles of
[] -> error' "please provide one or more input files as arguments" -- PARTIAL:
[] -> error' "please provide one or more data files as arguments" -- PARTIAL:
fs -> do
enewjandlatestdatesforfiles <- runExceptT $ readJournalFilesAndLatestDates iopts' fs
case enewjandlatestdatesforfiles of