TclCommandListSys.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. description = '%s %s' % ("--", "Outputs in Tcl Shell the list with the names of system variables.")
  17. # Dictionary of types from Tcl command, needs to be ordered
  18. arg_names = collections.OrderedDict([
  19. ('selection', str),
  20. ])
  21. # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
  22. option_types = collections.OrderedDict([
  23. ])
  24. # array of mandatory options for current Tcl command: required = {'name','outname'}
  25. required = []
  26. # structured help for current command, args needs to be ordered
  27. help = {
  28. 'main': "Returns the list of the names of system variables.\n"
  29. "Without an argument it will list all the system parameters. "
  30. "As an argument use first letter or first letters from the name "
  31. "of the system variable.\n"
  32. "In that case it will list only the system variables that starts with that string.\n"
  33. "Main categories start with: gerber or excellon or geometry or cncjob or global.\n"
  34. "Note: Use 'get_sys system variable' to get the value and 'set_sys system variable value' to set it.\n",
  35. 'args': collections.OrderedDict([
  36. ]),
  37. 'examples': ['list_sys',
  38. 'list_sys ser',
  39. 'list_sys gerber',
  40. 'list_sys cncj']
  41. }
  42. def execute(self, args, unnamed_args):
  43. """
  44. :param args:
  45. :param unnamed_args:
  46. :return:
  47. """
  48. if 'selection' in args:
  49. argument = args['selection']
  50. return str([k for k in self.app.defaults.keys() if str(k).startswith(str(argument))])
  51. else:
  52. ret_val = list(self.app.defaults.keys())
  53. return str(ret_val)
  54. # return str([*self.app.defaults])