jrnl.py:cli -> cli.py:run

This commit is contained in:
Manuel Ebert 2013-11-29 10:23:09 -08:00
parent 5bc18a5307
commit f22ddd706b
4 changed files with 15 additions and 6 deletions

View file

@ -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!

View file

@ -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

12
jrnl/jrnl.py → jrnl/cli.py Executable file → Normal file
View file

@ -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()

View file

@ -82,7 +82,7 @@ setup(
long_description=__doc__,
entry_points={
'console_scripts': [
'jrnl = jrnl:cli',
'jrnl = jrnl:run',
],
},
classifiers=[