tests for UI and better handling of quiet/verbose
authorAlexander Solovyov <piranha@piranha.org.ua>
Fri, 26 Jun 2009 10:03:21 +0300
changeset 16 4c5c6e56c903
parent 15 9477d21dc845
child 17 5736d050a5a4
tests for UI and better handling of quiet/verbose
fancycmd.py
test.py
--- a/fancycmd.py	Fri Jun 26 09:55:34 2009 +0300
+++ b/fancycmd.py	Fri Jun 26 10:03:21 2009 +0300
@@ -99,7 +99,8 @@
                                                        globalopts)
 
     ui.verbose = globaloptions['verbose']
-    ui.quiet = globaloptions['quiet']
+    # see UI.__init__ for explanation
+    ui.quiet = (not ui.verbose and globaloptions['quiet'])
 
     if globaloptions['help']:
         return cmdtable['help'][0](ui, cmd)
@@ -201,7 +202,8 @@
 
     def __init__(self, verbose=False, quiet=False):
         self.verbose = verbose
-        self.quiet = quiet
+        # disabling quiet in favor of verbose is more safe
+        self.quiet = (not verbose and quiet)
 
     def write(self, *messages):
         for m in messages:
--- a/test.py	Fri Jun 26 09:55:34 2009 +0300
+++ b/test.py	Fri Jun 26 10:03:21 2009 +0300
@@ -17,7 +17,12 @@
 
     Let's try to do that (damn, but what?!)
     '''
-    print args, opts
+    # test ui
+    ui.write('what the?!\n')
+    ui.warn('this is stderr\n')
+    ui.status('this would be invisible in quiet mode\n')
+    ui.note('this would be visible only in verbose mode\n')
+    ui.write('%s, %s\n' % (args, opts))
 
 cmdtable = {
     'simple':