Skip to content
Snippets Groups Projects
Commit aca90974 authored by Johannes Kung's avatar Johannes Kung
Browse files

Fixed CLI print bug and removed unnecessary command

parent 43cef2ba
No related branches found
No related tags found
1 merge request!14Updated CLI help text + refactoring
......@@ -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")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment