TclCommandListSys.py 2.4 KB

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