Added a command that clears the current ruleset.
authorimode <immediate.mode@gmail.com>
Mon, 12 Nov 2018 09:01:13 +0000 (01:01 -0800)
committerimode <immediate.mode@gmail.com>
Mon, 12 Nov 2018 09:01:13 +0000 (01:01 -0800)
modal.py

index ba882fb..5a7a47d 100644 (file)
--- a/modal.py
+++ b/modal.py
@@ -219,8 +219,9 @@ def help():
     prefix = ' ' * 4;
     print("Commands:");
     print(prefix + "rules : Display the current ruleset.");
-    print(prefix + "quit  : Quit.");
+    print(prefix + "clear : Clear the current ruleset.");
     print(prefix + "help  : This message.");
+    print(prefix + "quit  : Quit.");
 
 def main():
     if len(sys.argv) >= 2:
@@ -237,8 +238,6 @@ def main():
         input = prompt("::> ");
         if input == None:
             break;
-        elif parse(input) == parse("quit") or parse(input) == parse("exit"):
-            break;
         elif parse(input) == parse("rules"):
             print("Rules:");
             prefix = ' ' * 4;
@@ -252,8 +251,12 @@ def main():
             else:
                 pattern, replacement = line;
                 content              = content + [rule(pattern, replacement)];
+        elif parse(input) == parse("clear"):
+            content = [];
         elif parse(input) == parse("help"):
             help();
+        elif parse(input) == parse("quit") or parse(input) == parse("exit"):
+            break;
         else:
             print(inspect(seek(run(content, parse(input)), ["SRT"])));
     return;