diff --git a/src/simudator/cli/cli.py b/src/simudator/cli/cli.py index 201bb48c4e6ad87f12873758b3f05f3ab11d244a..a375743567c885d6d9f284ab2d6413db0828b4b2 100644 --- a/src/simudator/cli/cli.py +++ b/src/simudator/cli/cli.py @@ -13,7 +13,7 @@ CLI control: Simulation control: - n [x], next [x]: Simulates x ticks. - If no x is given simulates one tick. + If no x is given, simulates one tick. - rc, run_continuously: Continuously simulate ticks until a HALT is signalled @@ -29,12 +29,10 @@ State information: - p, print: Prints all states of all modules. - - p [name*], print [name*]: - Prints the states with given name. Prints all modules if no names are given. - - - pl, printlist [add/remove]: - Prints all modules in the print list. Add or remove followed by a modules - name will add or remove them from the print list. + - pl, printlist [add/remove] [module name] ...: + Add or remove the given modules to a list of modules to print. If no + arguments are given, i.e. "pl" or "printlist" on their own, all the modules + in the list will be printed. - pp, pretty print: Prints relevant processor state information in a readable and compact format. @@ -186,16 +184,6 @@ class CLI: module.print_module() print("\n") - case ["p", *_] | ["print", *_]: - print("\n") - # print modules with given names - for name in user_input.split()[1:]: - try: - self.processor.get_module(name).print_module() - print("\n") - except KeyError: - print("\nNo module named", name, "\n") - case ["pl", *_] | ["printlist", *_]: self.print_list_command(user_input.split()) @@ -325,24 +313,25 @@ class CLI: print("\n") return + names = user_input[2:] # add name to print list if user_input[1] == "add": - name = user_input[2] - # check if name exists - try: - self.processor.get_module(name) - except KeyError: - print("\nNo module named", name, "\n") - return + for name in names: + # check if name exists + try: + self.processor.get_module(name) + if name not in self.print_list: + self.print_list.append(name) + except KeyError: + print("No module named", name,) - self.print_list.append(name) elif user_input[1] == "remove": - name = user_input[2] - if name in self.print_list: - self.print_list.remove(name) - else: - print(name, "not in print list") + for name in names: + if name in self.print_list: + self.print_list.remove(name) + else: + print(name, "not in print list") else: print("Unknown command")