From 4d8949bbed1c638395b7373281661c6d1247674c Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Mon, 9 Dec 2013 13:28:19 -0800 Subject: [PATCH] Get rid of --delete --- docs/usage.rst | 32 +++++++++++--------------------- jrnl/cli.py | 18 +----------------- 2 files changed, 12 insertions(+), 38 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index 04ffb7aa..63597236 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -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. -Editing and deleting entries ----------------------------- +Editing older entries +--------------------- -Deleting -~~~~~~~~ - - -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 `). It behaves the same way ``--delete`` does, ie. :: +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 `): 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... diff --git a/jrnl/cli.py b/jrnl/cli.py index a0150163..fb5a03ae 100644 --- a/jrnl/cli.py +++ b/jrnl/cli.py @@ -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('--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('--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") 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""" compose = True 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 export = True 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) 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: other_entries = [e for e in old_entries if e not in journal.entries] # Edit