Add a new clear method in the Output class
[snf-image-creator] / image_creator / output / cli.py
index c7b5a55..37022d5 100644 (file)
@@ -58,6 +58,12 @@ def success(msg, new_line=True, colored=True):
     output(msg, new_line, color)
 
 
+def clear():
+    #clear the page
+    if sys.stderr.isatty():
+        sys.stderr.write('\033[H\033[2J')
+
+
 class SilentOutput(Output):
     pass
 
@@ -78,6 +84,9 @@ class SimpleOutput(Output):
     def output(self, msg='', new_line=True):
         output(msg, new_line)
 
+    def clear(self):
+        clear()
+
 
 class OutputWthProgress(SimpleOutput):
     class _Progress(Bar):