MCPcopy Create free account
hub / github.com/EasyIME/PIME / print_help

Method print_help

python/python3/tornado/options.py:438–466  ·  view source on GitHub ↗

Prints all the command line options to stderr (or another file).

(self, file: Optional[TextIO] = None)

Source from the content-addressed store, hash-verified

436 self.run_parse_callbacks()
437
438 def print_help(self, file: Optional[TextIO] = None) -> None:
439 """Prints all the command line options to stderr (or another file)."""
440 if file is None:
441 file = sys.stderr
442 print("Usage: %s [OPTIONS]" % sys.argv[0], file=file)
443 print("\nOptions:\n", file=file)
444 by_group = {} # type: Dict[str, List[_Option]]
445 for option in self._options.values():
446 by_group.setdefault(option.group_name, []).append(option)
447
448 for filename, o in sorted(by_group.items()):
449 if filename:
450 print("\n%s options:\n" % os.path.normpath(filename), file=file)
451 o.sort(key=lambda option: option.name)
452 for option in o:
453 # Always print names with dashes in a CLI context.
454 prefix = self._normalize_name(option.name)
455 if option.metavar:
456 prefix += "=" + option.metavar
457 description = option.help or ""
458 if option.default is not None and option.default != "":
459 description += " (default %s)" % option.default
460 lines = textwrap.wrap(description, 79 - 35)
461 if len(prefix) > 30 or len(lines) == 0:
462 lines.insert(0, "")
463 print(" --%-30s %s" % (prefix, lines[0]), file=file)
464 for line in lines[1:]:
465 print("%-34s %s" % (" ", line), file=file)
466 print(file=file)
467
468 def _help_callback(self, value: bool) -> None:
469 if value:

Callers 4

parse_command_lineMethod · 0.95
_help_callbackMethod · 0.95
print_helpFunction · 0.80

Calls 4

_normalize_nameMethod · 0.95
itemsMethod · 0.80
printFunction · 0.50
appendMethod · 0.45

Tested by 1