diff --git a/CHANGELOG.md b/CHANGELOG.md index 37b419d9..c4ba7ec9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Changelog ### 1.6 (November 5, 2013) +* __1.6.6__ -v prints the current version, also better strings for windows users. Furthermore, jrnl/jrnl.py moved to jrnl/cli.py * __1.6.5__ Allows composing multi-line entries on the command line or importing files * __1.6.4__ Fixed a bug that caused creating encrypted journals to fail * __1.6.3__ New, pretty, _useful_ documentation! diff --git a/jrnl/__init__.py b/jrnl/__init__.py index 81d5e4ab..ca25074f 100644 --- a/jrnl/__init__.py +++ b/jrnl/__init__.py @@ -7,11 +7,11 @@ jrnl is a simple journal application for your command line. """ __title__ = 'jrnl' -__version__ = '1.6.5' +__version__ = '1.6.6' __author__ = 'Manuel Ebert' __license__ = 'MIT License' __copyright__ = 'Copyright 2013 Manuel Ebert' from . import Journal -from . import jrnl -from .jrnl import cli +from . import cli +from .cli import run diff --git a/jrnl/jrnl.py b/jrnl/cli.py old mode 100755 new mode 100644 similarity index 96% rename from jrnl/jrnl.py rename to jrnl/cli.py index 451ddbdc..4349f716 --- a/jrnl/jrnl.py +++ b/jrnl/cli.py @@ -12,11 +12,13 @@ try: from . import util from . import exporters from . import install + from . import __version__ except (SystemError, ValueError): import Journal import util import exporters import install +import jrnl import os import tempfile import subprocess @@ -30,6 +32,8 @@ PYCRYPTO = install.module_exists("Crypto") def parse_args(args=None): parser = argparse.ArgumentParser() + parser.add_argument('-v', '--version', dest='version', action="store_true", help="prints version information and exits") + composing = parser.add_argument_group('Composing', 'To write an entry simply write it on the command line, e.g. "jrnl yesterday at 1pm: Went to the gym."') composing.add_argument('text', metavar='', nargs="*") @@ -116,7 +120,7 @@ def update_config(config, new_config, scope, force_local=False): else: config.update(new_config) -def cli(manual_args=None): +def run(manual_args=None): if not os.path.exists(CONFIG_PATH): config = install.install_jrnl(CONFIG_PATH) else: @@ -131,6 +135,10 @@ def cli(manual_args=None): args = parse_args(manual_args) + if args.version: + print("{} version {}".format(jrnl.__title__, jrnl.__version__)) + sys.exit(0) + # 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' @@ -230,4 +238,4 @@ def cli(manual_args=None): journal.write() if __name__ == "__main__": - cli() + run() diff --git a/setup.py b/setup.py index 668a44d9..e79aa3e0 100644 --- a/setup.py +++ b/setup.py @@ -82,7 +82,7 @@ setup( long_description=__doc__, entry_points={ 'console_scripts': [ - 'jrnl = jrnl:cli', + 'jrnl = jrnl:run', ], }, classifiers=[