Better use of ui in commands.

main
Olivier Mangin 12 years ago
parent e404c9e5b3
commit b514ab0dde

@ -12,8 +12,8 @@ def parser(subparsers, config):
parser.add_argument('-p', '--path', default=None, parser.add_argument('-p', '--path', default=None,
help='path to papers directory (if none, ~/.papers is used)') help='path to papers directory (if none, ~/.papers is used)')
parser.add_argument('-d', '--doc-dir', default=None, parser.add_argument('-d', '--doc-dir', default=None,
help=('path to document directory ' help=('path to document directory (if none, documents '
'(if none, documents are stored in the same directory)')) 'are stored in the same directory)'))
return parser return parser
@ -33,4 +33,4 @@ def command(config, ui, path, doc_dir):
else: else:
ui.error('papers already present in {}.'.format( ui.error('papers already present in {}.'.format(
ui.colored(papersdir, 'filepath'))) ui.colored(papersdir, 'filepath')))
exit(-1) ui.exit()

@ -1,6 +1,5 @@
import subprocess import subprocess
from ..color import colored
from .. import repo from .. import repo
from ..paper import NoDocumentFile from ..paper import NoDocumentFile
from .. import configs from .. import configs
@ -19,9 +18,10 @@ def command(config, ui, citekey):
paper = rp.paper_from_ref(citekey, fatal=True) paper = rp.paper_from_ref(citekey, fatal=True)
try: try:
filepath = paper.get_document_path() filepath = paper.get_document_path()
subprocess.Popen([config.get(configs.MAIN_SECTION, 'open-cmd'), filepath]) subprocess.Popen([config.get(configs.MAIN_SECTION, 'open-cmd'),
print("%s opened." % colored(filepath, 'filepath')) filepath])
print("%s opened." % ui.colored(filepath, 'filepath'))
except NoDocumentFile: except NoDocumentFile:
print("%s: No document associated to this entry %s." ui.error("No document associated with the entry %s."
% (colored('error', 'error'), colored(citekey, 'citekey'))) % ui.colored(citekey, 'citekey'))
exit(-1) ui.exit()

Loading…
Cancel
Save