TclCommandListSys.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. from tclCommands.TclCommand import *
  2. class TclCommandListSys(TclCommand):
  3. """
  4. Tcl shell command to get the list of system variables
  5. example:
  6. list_sys
  7. """
  8. # List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
  9. aliases = ['list_sys', 'listsys']
  10. # Dictionary of types from Tcl command, needs to be ordered
  11. arg_names = collections.OrderedDict([
  12. ('selection', str),
  13. ])
  14. # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
  15. option_types = collections.OrderedDict([
  16. ])
  17. # array of mandatory options for current Tcl command: required = {'name','outname'}
  18. required = []
  19. # structured help for current command, args needs to be ordered
  20. help = {
  21. 'main': "Returns the list of the names of system variables.\n"
  22. "Without a parameter it will list all the system parameters. "
  23. "As a parameter use first letter or first letters from the name "
  24. "of the system variable.\n"
  25. "In that case it will list only the system variables that starts with that string.\n"
  26. "Main categories start with: gerber or excellon or geometry or cncjob or global.\n"
  27. "Note: Use get_sys command to get the value and set_sys command to set it.\n",
  28. 'args': collections.OrderedDict([
  29. ]),
  30. 'examples': ['list_sys',
  31. 'list_sys gerber',
  32. 'list_sys cncjob']
  33. }
  34. def execute(self, args, unnamed_args):
  35. """
  36. :param args:
  37. :param unnamed_args:
  38. :return:
  39. """
  40. if 'selection' in args:
  41. argument = args['selection']
  42. print(argument)
  43. return str([k for k in self.app.defaults.keys() if str(k).startswith(str(argument))])
  44. else:
  45. return str([*self.app.defaults])