mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
commit
490ba01a2e
7 changed files with 31 additions and 16 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!
|
||||||
|
|
|
@ -34,3 +34,9 @@ Feature: Basic reading and writing to a journal
|
||||||
Then we should get no error
|
Then we should get no error
|
||||||
and the journal should contain "2013-07-25 09:00 I saw Elvis."
|
and the journal should contain "2013-07-25 09:00 I saw Elvis."
|
||||||
and the journal should contain "He's alive."
|
and the journal should contain "He's alive."
|
||||||
|
|
||||||
|
Scenario: Displaying the version number
|
||||||
|
Given we use the config "basic.json"
|
||||||
|
When we run "jrnl -v"
|
||||||
|
Then we should get no error
|
||||||
|
Then the output should contain "version"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from behave import *
|
from behave import *
|
||||||
import shutil
|
import shutil
|
||||||
import os
|
import os
|
||||||
from jrnl import jrnl
|
import jrnl
|
||||||
try:
|
try:
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from behave import *
|
from behave import *
|
||||||
from jrnl import jrnl, Journal, util
|
from jrnl import cli, Journal, util
|
||||||
from dateutil import parser as date_parser
|
from dateutil import parser as date_parser
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -27,14 +27,14 @@ def _parse_args(command):
|
||||||
return nargs
|
return nargs
|
||||||
|
|
||||||
def read_journal(journal_name="default"):
|
def read_journal(journal_name="default"):
|
||||||
with open(jrnl.CONFIG_PATH) as config_file:
|
with open(cli.CONFIG_PATH) as config_file:
|
||||||
config = json.load(config_file)
|
config = json.load(config_file)
|
||||||
with open(config['journals'][journal_name]) as journal_file:
|
with open(config['journals'][journal_name]) as journal_file:
|
||||||
journal = journal_file.read()
|
journal = journal_file.read()
|
||||||
return journal
|
return journal
|
||||||
|
|
||||||
def open_journal(journal_name="default"):
|
def open_journal(journal_name="default"):
|
||||||
with open(jrnl.CONFIG_PATH) as config_file:
|
with open(cli.CONFIG_PATH) as config_file:
|
||||||
config = json.load(config_file)
|
config = json.load(config_file)
|
||||||
journal_conf = config['journals'][journal_name]
|
journal_conf = config['journals'][journal_name]
|
||||||
if type(journal_conf) is dict: # We can override the default config on a by-journal basis
|
if type(journal_conf) is dict: # We can override the default config on a by-journal basis
|
||||||
|
@ -46,7 +46,7 @@ def open_journal(journal_name="default"):
|
||||||
@given('we use the config "{config_file}"')
|
@given('we use the config "{config_file}"')
|
||||||
def set_config(context, config_file):
|
def set_config(context, config_file):
|
||||||
full_path = os.path.join("features/configs", config_file)
|
full_path = os.path.join("features/configs", config_file)
|
||||||
jrnl.CONFIG_PATH = os.path.abspath(full_path)
|
cli.CONFIG_PATH = os.path.abspath(full_path)
|
||||||
|
|
||||||
@when('we run "{command}" and enter')
|
@when('we run "{command}" and enter')
|
||||||
@when('we run "{command}" and enter "{inputs}"')
|
@when('we run "{command}" and enter "{inputs}"')
|
||||||
|
@ -54,9 +54,9 @@ def run_with_input(context, command, inputs=None):
|
||||||
text = inputs or context.text
|
text = inputs or context.text
|
||||||
args = _parse_args(command)
|
args = _parse_args(command)
|
||||||
buffer = StringIO(text.strip())
|
buffer = StringIO(text.strip())
|
||||||
jrnl.util.STDIN = buffer
|
util.STDIN = buffer
|
||||||
try:
|
try:
|
||||||
jrnl.cli(args or None)
|
cli.run(args or None)
|
||||||
context.exit_status = 0
|
context.exit_status = 0
|
||||||
except SystemExit as e:
|
except SystemExit as e:
|
||||||
context.exit_status = e.code
|
context.exit_status = e.code
|
||||||
|
@ -65,7 +65,7 @@ def run_with_input(context, command, inputs=None):
|
||||||
def run(context, command):
|
def run(context, command):
|
||||||
args = _parse_args(command)
|
args = _parse_args(command)
|
||||||
try:
|
try:
|
||||||
jrnl.cli(args or None)
|
cli.run(args or None)
|
||||||
context.exit_status = 0
|
context.exit_status = 0
|
||||||
except SystemExit as e:
|
except SystemExit as e:
|
||||||
context.exit_status = e.code
|
context.exit_status = e.code
|
||||||
|
@ -154,7 +154,7 @@ def check_journal_content(context, text, journal_name="default"):
|
||||||
|
|
||||||
@then('journal "{journal_name}" should not exist')
|
@then('journal "{journal_name}" should not exist')
|
||||||
def journal_doesnt_exist(context, journal_name="default"):
|
def journal_doesnt_exist(context, journal_name="default"):
|
||||||
with open(jrnl.CONFIG_PATH) as config_file:
|
with open(cli.CONFIG_PATH) as config_file:
|
||||||
config = json.load(config_file)
|
config = json.load(config_file)
|
||||||
journal_path = config['journals'][journal_name]
|
journal_path = config['journals'][journal_name]
|
||||||
assert not os.path.exists(journal_path)
|
assert not os.path.exists(journal_path)
|
||||||
|
@ -168,7 +168,7 @@ def config_var(context, key, value, journal=None):
|
||||||
"int": int,
|
"int": int,
|
||||||
"str": str
|
"str": str
|
||||||
}[t](value)
|
}[t](value)
|
||||||
with open(jrnl.CONFIG_PATH) as config_file:
|
with open(cli.CONFIG_PATH) as config_file:
|
||||||
config = json.load(config_file)
|
config = json.load(config_file)
|
||||||
if journal:
|
if journal:
|
||||||
config = config["journals"][journal]
|
config = config["journals"][journal]
|
||||||
|
|
|
@ -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("{0} version {1}".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