Better use of ui in commands.
This commit is contained in:
parent
e404c9e5b3
commit
b514ab0dde
@ -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()
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user