TclCommandOptions.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from tclCommands.TclCommand import TclCommandSignaled
  2. import collections
  3. class TclCommandOptions(TclCommandSignaled):
  4. """
  5. Tcl shell command to open an Excellon file.
  6. """
  7. # array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
  8. aliases = ['options']
  9. description = '%s %s' % ("--", "Will return the options (settings) for an object as a string "
  10. "with values separated by \\n.")
  11. # Dictionary of types from Tcl command, needs to be ordered.
  12. # For positional arguments
  13. arg_names = collections.OrderedDict([
  14. ('name', str)
  15. ])
  16. # Dictionary of types from Tcl command, needs to be ordered.
  17. # For options like -optionname value
  18. option_types = collections.OrderedDict([
  19. ])
  20. # array of mandatory options for current Tcl command: required = {'name','outname'}
  21. required = ['name']
  22. # structured help for current command, args needs to be ordered
  23. help = {
  24. 'main': "Will return the options (settings) for an object as a string with values separated by \\n.",
  25. 'args': collections.OrderedDict([
  26. ('name', 'Object name for which to return the options. Required.'),
  27. ]),
  28. 'examples': ['options obj_name']
  29. }
  30. def execute(self, args, unnamed_args):
  31. """
  32. execute current TCL shell command
  33. :param args: array of known named arguments and options
  34. :param unnamed_args: array of other values which were passed into command
  35. without -somename and we do not have them in known arg_names
  36. :return: None or exception
  37. """
  38. name = args['name']
  39. ops = self.app.collection.get_by_name(str(name)).options
  40. return '\n'.join(["%s: %s" % (o, ops[o]) for o in ops])