Merge pull request #109 from maebert/piping

Piping data into jrnl
This commit is contained in:
Manuel Ebert 2013-11-24 11:34:56 -08:00
commit f2b3f56993
5 changed files with 15 additions and 4 deletions

View file

@ -3,6 +3,7 @@ Changelog
### 1.6 (November 5, 2013)
* __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!
* __1.6.2__ Starring entries now works for plain-text journals too!

View file

@ -15,6 +15,9 @@ Composing mode is entered by either starting ``jrnl`` without any arguments -- w
jrnl today at 3am: I just met Steve Buscemi in a bar! He looked funny.
You can also import an entry directly from a file::
jrnl < my_entry.txt
Smart timestamps
~~~~~~~~~~~~~~~~

View file

@ -7,7 +7,7 @@ jrnl is a simple journal application for your command line.
"""
__title__ = 'jrnl'
__version__ = '1.6.4'
__version__ = '1.6.5'
__author__ = 'Manuel Ebert'
__license__ = 'MIT License'
__copyright__ = 'Copyright 2013 Manuel Ebert'

View file

@ -157,10 +157,13 @@ def cli(manual_args=None):
journal = Journal.Journal(journal_name, **config)
if mode_compose and not args.text:
if config['editor']:
if not sys.stdin.isatty():
# Piping data into jrnl
raw = util.py23_read()
elif config['editor']:
raw = get_text_from_editor(config)
else:
raw = util.py23_input("[Compose Entry] ")
raw = util.py23_read("[Compose Entry, press Ctrl+D to finish writing]\n")
if raw:
args.text = [raw]
else:

View file

@ -65,10 +65,14 @@ def prompt(msg):
msg += "\n"
STDERR.write(u(msg))
def py23_input(msg):
def py23_input(msg=""):
STDERR.write(u(msg))
return STDIN.readline().strip()
def py23_read(msg=""):
STDERR.write(u(msg))
return STDIN.read()
def yesno(prompt, default=True):
prompt = prompt.strip() + (" [Y/n]" if default else " [y/N]")
raw = py23_input(prompt)