From b514ab0ddef13f1867720d03b8cc1a28aa8269cf Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Tue, 11 Jun 2013 12:30:42 +0200 Subject: [PATCH] Better use of ui in commands. --- papers/commands/init_cmd.py | 6 +++--- papers/commands/open_cmd.py | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/papers/commands/init_cmd.py b/papers/commands/init_cmd.py index 1d1b717..a2e9dc6 100644 --- a/papers/commands/init_cmd.py +++ b/papers/commands/init_cmd.py @@ -12,8 +12,8 @@ def parser(subparsers, config): parser.add_argument('-p', '--path', default=None, help='path to papers directory (if none, ~/.papers is used)') parser.add_argument('-d', '--doc-dir', default=None, - help=('path to document directory ' - '(if none, documents are stored in the same directory)')) + help=('path to document directory (if none, documents ' + 'are stored in the same directory)')) return parser @@ -33,4 +33,4 @@ def command(config, ui, path, doc_dir): else: ui.error('papers already present in {}.'.format( ui.colored(papersdir, 'filepath'))) - exit(-1) + ui.exit() diff --git a/papers/commands/open_cmd.py b/papers/commands/open_cmd.py index 221933d..559fd88 100644 --- a/papers/commands/open_cmd.py +++ b/papers/commands/open_cmd.py @@ -1,6 +1,5 @@ import subprocess -from ..color import colored from .. import repo from ..paper import NoDocumentFile from .. import configs @@ -19,9 +18,10 @@ def command(config, ui, citekey): paper = rp.paper_from_ref(citekey, fatal=True) try: filepath = paper.get_document_path() - subprocess.Popen([config.get(configs.MAIN_SECTION, 'open-cmd'), filepath]) - print("%s opened." % colored(filepath, 'filepath')) + subprocess.Popen([config.get(configs.MAIN_SECTION, 'open-cmd'), + filepath]) + print("%s opened." % ui.colored(filepath, 'filepath')) except NoDocumentFile: - print("%s: No document associated to this entry %s." - % (colored('error', 'error'), colored(citekey, 'citekey'))) - exit(-1) + ui.error("No document associated with the entry %s." + % ui.colored(citekey, 'citekey')) + ui.exit()