cli: Add verbose and noln parameters to error() and status()

This commit is contained in:
Ozan Çağlayan
2011-06-07 10:50:12 +00:00
parent f65dae8c6e
commit be2967c191
2 changed files with 9 additions and 7 deletions
+7 -5
View File
@@ -118,15 +118,17 @@ class CLI(pisi.ui.UI):
else: else:
self.output(pisi.util.colorize(msg + '\n', 'brightyellow'), err=True, verbose=verbose) self.output(pisi.util.colorize(msg + '\n', 'brightyellow'), err=True, verbose=verbose)
def error(self, msg): def error(self, msg, noln = False):
msg = unicode(msg) msg = unicode(msg)
self.errors += 1 self.errors += 1
if not noln:
msg = '%s\n' % msg
if ctx.log: if ctx.log:
ctx.log.error(msg) ctx.log.error(msg)
if ctx.get_option('no_color'): if ctx.get_option('no_color'):
self.output(_('Error: ') + msg + '\n', err=True) self.output(_('Error: ') + msg, err=True)
else: else:
self.output(pisi.util.colorize(msg + '\n', 'brightred'), err=True) self.output(pisi.util.colorize(msg, 'brightred'), err=True)
def action(self, msg, verbose = False): def action(self, msg, verbose = False):
#TODO: this seems quite redundant? #TODO: this seems quite redundant?
@@ -184,10 +186,10 @@ class CLI(pisi.ui.UI):
if ka['percent'] == 100: if ka['percent'] == 100:
self.output(pisi.util.colorize(_(' [complete]\n'), 'gray')) self.output(pisi.util.colorize(_(' [complete]\n'), 'gray'))
def status(self, msg = None): def status(self, msg = None, verbose = False):
if msg: if msg:
msg = unicode(msg) msg = unicode(msg)
self.output(pisi.util.colorize(msg + '\n', 'brightgreen')) self.output(pisi.util.colorize(msg + '\n', 'brightgreen'), verbose=verbose)
pisi.util.xterm_title(msg) pisi.util.xterm_title(msg)
def notify(self, event, **keywords): def notify(self, event, **keywords):
+2 -2
View File
@@ -68,7 +68,7 @@ class UI(object):
"warn the user" "warn the user"
pass pass
def error(self,msg): def error(self, msg, noln = False):
"inform a (possibly fatal) error" "inform a (possibly fatal) error"
pass pass
@@ -90,7 +90,7 @@ class UI(object):
"display progress" "display progress"
pass pass
def status(self, msg = None): def status(self, msg = None, verbose = False):
"set status, if not given clear it" "set status, if not given clear it"
pass pass