Get rid of --delete

This commit is contained in:
Manuel Ebert 2013-12-09 13:28:19 -08:00
parent fabb8d5f1b
commit 4d8949bbed
2 changed files with 12 additions and 38 deletions

View file

@ -85,29 +85,19 @@ 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.
Editing and deleting entries Editing older entries
---------------------------- ---------------------
Deleting You can edit selected entries after you wrote them. This is particularly useful when your journal file is encrypted or if you're using a DayOne journal. To use this feature, you need to have an editor configured in your journal configuration file (see :doc:`advanced usage <advanced>`):
~~~~~~~~
Use ``--delete`` to delete entries from your journal. This will only affect selected entries, e.g. ::
jrnl -n 1 --delete
will delete the last entry, ::
jrnl @girlfriend -until 'june 2012' --delete
will delete all entries tagged with ``@girlfriend`` written before June 2012. ``jrnl --delete`` would delete your **entire** journal, which is often not what you want. You will be shown the titles of the entries which are about to be deleted before you have to confirm the deletion.
Editing
~~~~~~~
You can also edit selected entries after you wrote them. This is particularly useful when your journal file is encrypted. To use this feature, you need to have an editor configured in your journal configuration file (see :doc:`advanced usage <advanced>`). It behaves the same way ``--delete`` does, ie. ::
jrnl -until 1950 @texas -and @history --edit jrnl -until 1950 @texas -and @history --edit
Will edit all entries tagged with ``@texas`` and ``@history`` before 1950. Of course, if you are using multiple journals, you can also edit e.g. the entry of your work journal with ``jrnl work -n 1 --edit``. In any case, this will bring up your editor and save (and, if applicable, encrypt) your edited journal after you save and exit the editor. Will open your editor with all entries tagged with ``@texas`` and ``@history`` before 1950. You can make any changes to them you want; after you save the file and close the editor, your journal will be updated.
Of course, if you are using multiple journals, you can also edit e.g. the entry of your work journal with ``jrnl work -n 1 --edit``. In any case, this will bring up your editor and save (and, if applicable, encrypt) your edited journal after you save and exit the editor.
You can also use this feature for deleting entries from your journal::
jrnl @girlfriend -until 'june 2012' --edit
Just select all text, press delete, and everything is gone...

View file

@ -49,7 +49,6 @@ def parse_args(args=None):
exporting.add_argument('-o', metavar='OUTPUT', dest='output', help='The output of the file can be provided when using with --export', default=False, const=None) exporting.add_argument('-o', metavar='OUTPUT', dest='output', help='The output of the file can be provided when using with --export', default=False, const=None)
exporting.add_argument('--encrypt', metavar='FILENAME', dest='encrypt', help='Encrypts your existing journal with a new password', nargs='?', default=False, const=None) exporting.add_argument('--encrypt', metavar='FILENAME', dest='encrypt', help='Encrypts your existing journal with a new password', nargs='?', default=False, const=None)
exporting.add_argument('--decrypt', metavar='FILENAME', dest='decrypt', help='Decrypts your journal and stores it in plain text', nargs='?', default=False, const=None) exporting.add_argument('--decrypt', metavar='FILENAME', dest='decrypt', help='Decrypts your journal and stores it in plain text', nargs='?', default=False, const=None)
exporting.add_argument('--delete', dest='delete', help='Deletes the selected entries your journal file.', action="store_true")
exporting.add_argument('--edit', dest='edit', help='Opens your editor to edit the selected entries.', action="store_true") exporting.add_argument('--edit', dest='edit', help='Opens your editor to edit the selected entries.', action="store_true")
return parser.parse_args(args) return parser.parse_args(args)
@ -58,7 +57,7 @@ def guess_mode(args, config):
"""Guesses the mode (compose, read or export) from the given arguments""" """Guesses the mode (compose, read or export) from the given arguments"""
compose = True compose = True
export = False export = False
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.delete, 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.limit, args.strict, args.starred)): elif any((args.start_date, args.end_date, args.limit, args.strict, args.starred)):
@ -217,21 +216,6 @@ def run(manual_args=None):
update_config(original_config, {"encrypt": False}, journal_name, force_local=True) update_config(original_config, {"encrypt": False}, journal_name, force_local=True)
install.save_config(original_config, config_path=CONFIG_PATH) install.save_config(original_config, config_path=CONFIG_PATH)
elif args.delete:
other_entries = [e for e in old_entries if e not in journal.entries]
util.prompt("Following entries will be deleted:")
for e in journal.entries[:10]:
util.prompt(" "+e.pprint(short=True))
if len(journal) > 10:
q = "...and {0} more. Do you really want to delete these entries?".format(len(journal) - 10)
else:
q = "Do you really want to delete these entries?"
ok = util.yesno(q, default=False)
if ok:
util.prompt("[Deleted {0} entries]".format(len(journal)))
journal.entries = other_entries
journal.write()
elif args.edit: elif args.edit:
other_entries = [e for e in old_entries if e not in journal.entries] other_entries = [e for e in old_entries if e not in journal.entries]
# Edit # Edit