MCPcopy Index your code
hub / github.com/httpie/cli / print_usage

Method print_usage

httpie/cli/argparser.py:575–596  ·  view source on GitHub ↗
(self, file)

Source from the content-addressed store, hash-verified

573 )
574
575 def print_usage(self, file):
576 from rich.text import Text
577 from httpie.output.ui import rich_help
578
579 whitelist = set()
580 _, exception, _ = sys.exc_info()
581 if (
582 isinstance(exception, argparse.ArgumentError)
583 and len(exception.args) >= 1
584 and isinstance(exception.args[0], argparse.Action)
585 and exception.args[0].option_strings
586 ):
587 # add_usage path is also taken when you pass an invalid option,
588 # e.g --style=invalid. If something like that happens, we want
589 # to include to action that caused to the invalid usage into
590 # the list of actions we are displaying.
591 whitelist.add(exception.args[0].option_strings[0])
592
593 usage_text = Text('usage', style='bold')
594 usage_text.append(':\n ')
595 usage_text.append(rich_help.to_usage(self.spec, whitelist=whitelist))
596 self.env.rich_error_console.print(usage_text)
597
598 def error(self, message):
599 """Prints a usage message incorporating the message to stderr and

Callers 1

errorMethod · 0.95

Calls 1

addMethod · 0.80

Tested by

no test coverage detected