mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-18 12:08:31 +02:00
Merge e00e7b9b7f
into 9fe8728d21
This commit is contained in:
commit
3e91743fe9
3 changed files with 17 additions and 3 deletions
|
@ -98,6 +98,17 @@ the last five entries containing both ``@pineapple`` **and** ``@lubricant``. You
|
||||||
|
|
||||||
``jrnl @pinkie @WorldDomination`` will switch to viewing mode because although **no** command line arguments are given, all the input strings look like tags - *jrnl* will assume you want to filter by tag.
|
``jrnl @pinkie @WorldDomination`` will switch to viewing mode because although **no** command line arguments are given, all the input strings look like tags - *jrnl* will assume you want to filter by tag.
|
||||||
|
|
||||||
|
Searching
|
||||||
|
---------
|
||||||
|
|
||||||
|
To search for a string ``"excellent idea"`` in all journal entries, use the ``-search`` argument::
|
||||||
|
|
||||||
|
jrnl -search "excellent idea"
|
||||||
|
|
||||||
|
The ``-search`` argument can be combined with other filters, such as ``-from`` and ``-until``.
|
||||||
|
|
||||||
|
Note that the searching is case-insensitive and doesn't accept any wildcards or regular expression syntax.
|
||||||
|
|
||||||
Editing older entries
|
Editing older entries
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ class Journal(object):
|
||||||
if n:
|
if n:
|
||||||
self.entries = self.entries[-n:]
|
self.entries = self.entries[-n:]
|
||||||
|
|
||||||
def filter(self, tags=[], start_date=None, end_date=None, starred=False, strict=False, short=False):
|
def filter(self, tags=[], start_date=None, end_date=None, starred=False, strict=False, short=False, search_plain=None):
|
||||||
"""Removes all entries from the journal that don't match the filter.
|
"""Removes all entries from the journal that don't match the filter.
|
||||||
|
|
||||||
tags is a list of tags, each being a string that starts with one of the
|
tags is a list of tags, each being a string that starts with one of the
|
||||||
|
@ -218,6 +218,7 @@ class Journal(object):
|
||||||
and (not starred or entry.starred)
|
and (not starred or entry.starred)
|
||||||
and (not start_date or entry.date >= start_date)
|
and (not start_date or entry.date >= start_date)
|
||||||
and (not end_date or entry.date <= end_date)
|
and (not end_date or entry.date <= end_date)
|
||||||
|
and (not search_plain or search_plain in entry.title or search_plain in entry.body)
|
||||||
]
|
]
|
||||||
if short:
|
if short:
|
||||||
if tags:
|
if tags:
|
||||||
|
|
|
@ -37,6 +37,7 @@ def parse_args(args=None):
|
||||||
reading = parser.add_argument_group('Reading', 'Specifying either of these parameters will display posts of your journal')
|
reading = parser.add_argument_group('Reading', 'Specifying either of these parameters will display posts of your journal')
|
||||||
reading.add_argument('-from', dest='start_date', metavar="DATE", help='View entries after this date')
|
reading.add_argument('-from', dest='start_date', metavar="DATE", help='View entries after this date')
|
||||||
reading.add_argument('-until', '-to', dest='end_date', metavar="DATE", help='View entries before this date')
|
reading.add_argument('-until', '-to', dest='end_date', metavar="DATE", help='View entries before this date')
|
||||||
|
reading.add_argument('-search', '-s', dest='search_plain', help='View entries containing a specific string')
|
||||||
reading.add_argument('-on', dest='on_date', metavar="DATE", help='View entries on this date')
|
reading.add_argument('-on', dest='on_date', metavar="DATE", help='View entries on this date')
|
||||||
reading.add_argument('-and', dest='strict', action="store_true", help='Filter by tags using AND (default: OR)')
|
reading.add_argument('-and', dest='strict', action="store_true", help='Filter by tags using AND (default: OR)')
|
||||||
reading.add_argument('-starred', dest='starred', action="store_true", help='Show only starred entries')
|
reading.add_argument('-starred', dest='starred', action="store_true", help='Show only starred entries')
|
||||||
|
@ -61,7 +62,7 @@ def guess_mode(args, config):
|
||||||
if args.decrypt is not False or args.encrypt is not False or args.export is not False or any((args.short, args.tags, args.edit)):
|
if args.decrypt is not False or args.encrypt is not False or args.export is not False or any((args.short, args.tags, args.edit)):
|
||||||
compose = False
|
compose = False
|
||||||
export = True
|
export = True
|
||||||
elif any((args.start_date, args.end_date, args.on_date, args.limit, args.strict, args.starred)):
|
elif any((args.start_date, args.end_date, args.on_date, args.limit, args.strict, args.starred, args.search_plain)):
|
||||||
# Any sign of displaying stuff?
|
# Any sign of displaying stuff?
|
||||||
compose = False
|
compose = False
|
||||||
elif args.text and all(word[0] in config['tagsymbols'] for word in " ".join(args.text).split()):
|
elif args.text and all(word[0] in config['tagsymbols'] for word in " ".join(args.text).split()):
|
||||||
|
@ -233,7 +234,8 @@ def run(manual_args=None):
|
||||||
start_date=args.start_date, end_date=args.end_date,
|
start_date=args.start_date, end_date=args.end_date,
|
||||||
strict=args.strict,
|
strict=args.strict,
|
||||||
short=args.short,
|
short=args.short,
|
||||||
starred=args.starred)
|
starred=args.starred,
|
||||||
|
search_plain=args.search_plain)
|
||||||
journal.limit(args.limit)
|
journal.limit(args.limit)
|
||||||
|
|
||||||
# Reading mode
|
# Reading mode
|
||||||
|
|
Loading…
Add table
Reference in a new issue