diff --git a/CHANGELOG.md b/CHANGELOG.md index 11f760b0..47886ade 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Changelog ### 1.7 (December 22, 2013) +* __1.7.10__ Supports `-3` as a shortcut for `-n 3` and updates to tzlocal 1.1 * __1.7.9__ Fix a logic bug so that jrnl -h and jrnl -v are possible even if jrnl not configured yet. * __1.7.8__ Upgrade to parsedatetime 1.2 * __1.7.7__ Cleaned up imports, better unicode support diff --git a/docs/usage.rst b/docs/usage.rst index 6ef0f390..0b7f487f 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -56,7 +56,7 @@ Viewing jrnl -n 10 -will list you the ten latest entries, :: +will list you the ten latest entries (if you're lazy, ``jrnl -10`` will do the same), :: jrnl -from "last year" -until march diff --git a/jrnl/__init__.py b/jrnl/__init__.py index 8842f8ec..12c55ed0 100644 --- a/jrnl/__init__.py +++ b/jrnl/__init__.py @@ -8,7 +8,7 @@ jrnl is a simple journal application for your command line. from __future__ import absolute_import __title__ = 'jrnl' -__version__ = '1.7.9' +__version__ = '1.7.10' __author__ = 'Manuel Ebert' __license__ = 'MIT License' __copyright__ = 'Copyright 2013 - 2014 Manuel Ebert' diff --git a/jrnl/cli.py b/jrnl/cli.py index 1538352a..fe00977d 100644 --- a/jrnl/cli.py +++ b/jrnl/cli.py @@ -35,7 +35,7 @@ def parse_args(args=None): reading.add_argument('-until', '-to', dest='end_date', metavar="DATE", help='View entries before this date') 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('-n', dest='limit', default=None, metavar="N", help='Shows the last n entries matching the filter', nargs="?", type=int) + reading.add_argument('-n', dest='limit', default=None, metavar="N", help="Shows the last n entries matching the filter. '-n 3' and '-3' have the same effect.", nargs="?", type=int) exporting = parser.add_argument_group('Export / Import', 'Options for transmogrifying your journal') exporting.add_argument('--short', dest='short', action="store_true", help='Show only titles or line containing the search tags') @@ -119,13 +119,19 @@ def run(manual_args=None): util.prompt("According to your jrnl_conf, your journal is encrypted, however PyCrypto was not found. To open your journal, install the PyCrypto package from http://www.pycrypto.org.") sys.exit(1) - - # If the first textual argument points to a journal file, # use this! journal_name = args.text[0] if (args.text and args.text[0] in config['journals']) else 'default' if journal_name is not 'default': args.text = args.text[1:] + # If the first remaining argument looks like e.g. '-3', interpret that as a limiter + if not args.limit and args.text and args.text[0].startswith("-"): + try: + args.limit = int(args.text[0].lstrip("-")) + args.text = args.text[1:] + except: + pass + journal_conf = config['journals'].get(journal_name) if type(journal_conf) is dict: # We can override the default config on a by-journal basis config.update(journal_conf)