mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-29 22:16:13 +02:00
Plugin architecture
This commit is contained in:
parent
a1b5a4099e
commit
6fed042b8b
9 changed files with 287 additions and 188 deletions
10
jrnl/cli.py
10
jrnl/cli.py
|
@ -10,8 +10,8 @@
|
|||
from __future__ import absolute_import, unicode_literals
|
||||
from . import Journal
|
||||
from . import util
|
||||
from . import exporters
|
||||
from . import install
|
||||
from . import plugins
|
||||
import jrnl
|
||||
import os
|
||||
import argparse
|
||||
|
@ -19,7 +19,6 @@ import sys
|
|||
|
||||
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")
|
||||
|
@ -39,7 +38,7 @@ def parse_args(args=None):
|
|||
exporting = parser.add_argument_group('Export / Import', 'Options for transmogrifying your journal')
|
||||
exporting.add_argument('--short', dest='short', action="store_true", help='Show only titles or line containing the search tags')
|
||||
exporting.add_argument('--tags', dest='tags', action="store_true", help='Returns a list of all tags and number of occurences')
|
||||
exporting.add_argument('--export', metavar='TYPE', dest='export', choices=['text', 'txt', 'markdown', 'md', 'json'], help='Export your journal. TYPE can be json, markdown, or text.', default=False, const=None)
|
||||
exporting.add_argument('--export', metavar='TYPE', dest='export', choices=plugins.BaseExporter.PLUGIN_NAMES, help='Export your journal. TYPE can be json, markdown, or text.', default=False, const=None)
|
||||
exporting.add_argument('-o', metavar='OUTPUT', dest='output', help='Optionally specifies output file when using --export. If OUTPUT is a directory, exports each entry into an individual file instead.', default=False, const=None)
|
||||
exporting.add_argument('--encrypt', metavar='FILENAME', dest='encrypt', help='Encrypts your existing journal with a new password', nargs='?', default=False, const=None)
|
||||
exporting.add_argument('--decrypt', metavar='FILENAME', dest='decrypt', help='Decrypts your journal and stores it in plain text', nargs='?', default=False, const=None)
|
||||
|
@ -218,10 +217,11 @@ def run(manual_args=None):
|
|||
print(util.py2encode(journal.pprint(short=True)))
|
||||
|
||||
elif args.tags:
|
||||
print(util.py2encode(exporters.to_tag_list(journal)))
|
||||
print(util.py2encode(plugins.get_exporter("tags").export(journal)))
|
||||
|
||||
elif args.export is not False:
|
||||
print(util.py2encode(exporters.export(journal, args.export, args.output)))
|
||||
exporter = plugins.get_exporter(args.export)
|
||||
print(exporter.export(journal, args.output))
|
||||
|
||||
elif (args.encrypt is not False or args.decrypt is not False) and not PYCRYPTO:
|
||||
util.prompt("PyCrypto not found. To encrypt or decrypt your journal, install the PyCrypto package from http://www.pycrypto.org.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue