Skip to content

Commit

Permalink
UI and doc for multiple PATTERNs (WIP)
Browse files Browse the repository at this point in the history
nothing else is actually implemented...

Related #11
  • Loading branch information
zacchiro committed May 25, 2024
1 parent 63eba32 commit ac73485
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,18 @@ Usage
The CLI says it all when invoked as `bean-grep --help`:

```
Usage: bean-grep [OPTIONS] [PATTERN] FILENAME...
Usage: bean-grep [OPTIONS] [PATTERN...] FILENAME...
Search for entries matching given criteria in Beancount journals. Pretty
print matching entries to standard output.
Search criteria can be specified with the options below and/or providing an
explicit "smart" PATTERN. If given, PATTERN is interpreted as described
below under "Patterns". If not given, search criteria are defined by
explicit options.
Search criteria can be specified with the options below and/or providing one
or more explicit "smart" PATTERNs. If given, PATTERNs are interpreted as
described below under "Patterns". If not given, search criteria are defined
by explicit options.
To pass multiple PATTERNs, separate them with newline characters. (Tip: you
can use shell quotes to make this easier on the CLI.)
Multiple options, options given mutiple times, and PATTERN(s) are logically
joined (AND-ed) together.
Expand Down Expand Up @@ -139,8 +142,8 @@ Options:
match is found. [default: no-quiet]
--skip-internals / --no-skip-internals
When matching, ignore internal information
not visible in the ledger. This includes the
automatic metadata: filename, lineno.
not visible in the journal. This includes
the automatic metadata: filename, lineno.
[default: skip-internals]
-v, --invert-match Invert the sense of matching: return entries
that do *not* match given criteria. This
Expand All @@ -156,7 +159,7 @@ Options:
Patterns:
When given the "smart" PATTERN is interpreted according to the following
When given each "smart" PATTERN is interpreted according to the following
heuristics, tried in order, first match wins:
- if it is in the form "YYYY-MM-DD" -> then it is interpreted as --date
Expand Down
15 changes: 9 additions & 6 deletions src/beangrep/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@
help="""Search for entries matching given criteria in Beancount journals. Pretty
print matching entries to standard output.
Search criteria can be specified with the options below and/or providing an explicit
"smart" PATTERN. If given, PATTERN is interpreted as described below under "Patterns".
If not given, search criteria are defined by explicit options.
Search criteria can be specified with the options below and/or providing one or more
explicit "smart" PATTERNs. If given, PATTERNs are interpreted as described below under
"Patterns". If not given, search criteria are defined by explicit options.
To pass multiple PATTERNs, separate them with newline characters. (Tip: you can use
shell quotes to make this easier on the CLI.)
Multiple options, options given mutiple times, and PATTERN(s) are logically joined
(AND-ed) together.
Expand All @@ -42,7 +45,7 @@
buffering of stdin.""",
epilog="""Patterns:
When given the "smart" PATTERN is interpreted according to the following heuristics,
When given each "smart" PATTERN is interpreted according to the following heuristics,
tried in order, first match wins:
- if it is in the form "YYYY-MM-DD" -> then it is interpreted as --date
Expand All @@ -69,7 +72,7 @@
"args",
required=True,
nargs=-1,
metavar="[PATTERN] FILENAME...", # override metavar to show what is required
metavar="[PATTERN...] FILENAME...", # override metavar to show what is required
)
@click.option(
"--account",
Expand Down Expand Up @@ -212,7 +215,7 @@
"skip_internals",
default=True,
show_default=True,
help=f"""When matching, ignore internal information not visible in the ledger. This
help=f"""When matching, ignore internal information not visible in the journal. This
includes the automatic metadata: {", ".join(sorted(INTERNALS_META))}.""",
)
@click.option(
Expand Down

0 comments on commit ac73485

Please sign in to comment.