mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
jrnl.py:cli -> cli.py:run
This commit is contained in:
parent
5bc18a5307
commit
f22ddd706b
4 changed files with 15 additions and 6 deletions
|
@ -3,6 +3,7 @@ Changelog
|
||||||
|
|
||||||
### 1.6 (November 5, 2013)
|
### 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.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.4__ Fixed a bug that caused creating encrypted journals to fail
|
||||||
* __1.6.3__ New, pretty, _useful_ documentation!
|
* __1.6.3__ New, pretty, _useful_ documentation!
|
||||||
|
|
|
@ -7,11 +7,11 @@ jrnl is a simple journal application for your command line.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__title__ = 'jrnl'
|
__title__ = 'jrnl'
|
||||||
__version__ = '1.6.5'
|
__version__ = '1.6.6'
|
||||||
__author__ = 'Manuel Ebert'
|
__author__ = 'Manuel Ebert'
|
||||||
__license__ = 'MIT License'
|
__license__ = 'MIT License'
|
||||||
__copyright__ = 'Copyright 2013 Manuel Ebert'
|
__copyright__ = 'Copyright 2013 Manuel Ebert'
|
||||||
|
|
||||||
from . import Journal
|
from . import Journal
|
||||||
from . import jrnl
|
from . import cli
|
||||||
from .jrnl import cli
|
from .cli import run
|
||||||
|
|
12
jrnl/jrnl.py → jrnl/cli.py
Executable file → Normal file
12
jrnl/jrnl.py → jrnl/cli.py
Executable file → Normal file
|
@ -12,11 +12,13 @@ try:
|
||||||
from . import util
|
from . import util
|
||||||
from . import exporters
|
from . import exporters
|
||||||
from . import install
|
from . import install
|
||||||
|
from . import __version__
|
||||||
except (SystemError, ValueError):
|
except (SystemError, ValueError):
|
||||||
import Journal
|
import Journal
|
||||||
import util
|
import util
|
||||||
import exporters
|
import exporters
|
||||||
import install
|
import install
|
||||||
|
import jrnl
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -30,6 +32,8 @@ PYCRYPTO = install.module_exists("Crypto")
|
||||||
|
|
||||||
def parse_args(args=None):
|
def parse_args(args=None):
|
||||||
parser = argparse.ArgumentParser()
|
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 = 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="*")
|
composing.add_argument('text', metavar='', nargs="*")
|
||||||
|
|
||||||
|
@ -116,7 +120,7 @@ def update_config(config, new_config, scope, force_local=False):
|
||||||
else:
|
else:
|
||||||
config.update(new_config)
|
config.update(new_config)
|
||||||
|
|
||||||
def cli(manual_args=None):
|
def run(manual_args=None):
|
||||||
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:
|
||||||
|
@ -131,6 +135,10 @@ def cli(manual_args=None):
|
||||||
|
|
||||||
args = parse_args(manual_args)
|
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,
|
# If the first textual argument points to a journal file,
|
||||||
# use this!
|
# use this!
|
||||||
journal_name = args.text[0] if (args.text and args.text[0] in config['journals']) else 'default'
|
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()
|
journal.write()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
cli()
|
run()
|
2
setup.py
2
setup.py
|
@ -82,7 +82,7 @@ setup(
|
||||||
long_description=__doc__,
|
long_description=__doc__,
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
'jrnl = jrnl:cli',
|
'jrnl = jrnl:run',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
classifiers=[
|
classifiers=[
|
||||||
|
|
Loading…
Add table
Reference in a new issue