Merge pull request #129 from maebert/fix-argparse

Fix a logic bug so that jrnl -h and jrnl -v are possible even if jrnl no...
This commit is contained in:
Manuel Ebert 2014-01-26 10:22:40 -08:00
commit 071773537b
3 changed files with 9 additions and 6 deletions

View file

@ -4,6 +4,7 @@ Changelog
### 1.7 (December 22, 2013) ### 1.7 (December 22, 2013)
* __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.8__ Upgrade to parsedatetime 1.2
* __1.7.7__ Cleaned up imports, better unicode support * __1.7.7__ Cleaned up imports, better unicode support
* __1.7.6__ Python 3 port for slugify * __1.7.6__ Python 3 port for slugify

View file

@ -8,7 +8,7 @@ jrnl is a simple journal application for your command line.
from __future__ import absolute_import from __future__ import absolute_import
__title__ = 'jrnl' __title__ = 'jrnl'
__version__ = '1.7.8' __version__ = '1.7.9'
__author__ = 'Manuel Ebert' __author__ = 'Manuel Ebert'
__license__ = 'MIT License' __license__ = 'MIT License'
__copyright__ = 'Copyright 2013 - 2014 Manuel Ebert' __copyright__ = 'Copyright 2013 - 2014 Manuel Ebert'

View file

@ -100,6 +100,13 @@ def update_config(config, new_config, scope, force_local=False):
config.update(new_config) config.update(new_config)
def run(manual_args=None): def run(manual_args=None):
args = parse_args(manual_args)
if args.version:
version_str = "{0} version {1}".format(jrnl.__title__, jrnl.__version__)
print(util.py2encode(version_str))
sys.exit(0)
if not os.path.exists(CONFIG_PATH): if not os.path.exists(CONFIG_PATH):
config = install.install_jrnl(CONFIG_PATH) config = install.install_jrnl(CONFIG_PATH)
else: else:
@ -112,12 +119,7 @@ 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.") 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) sys.exit(1)
args = parse_args(manual_args)
if args.version:
version_str = "{0} version {1}".format(jrnl.__title__, jrnl.__version__)
print(util.py2encode(version_str))
sys.exit(0)
# If the first textual argument points to a journal file, # If the first textual argument points to a journal file,
# use this! # use this!