MCPcopy Create free account
hub / github.com/bloomberg/pystack / generate_cli_parser

Function generate_cli_parser

src/pystack/__main__.py:107–260  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

105
106
107def generate_cli_parser() -> argparse.ArgumentParser:
108 general_options_parser = argparse.ArgumentParser(add_help=False)
109 general_options_parser.add_argument("-v", "--verbose", action="count", default=0)
110 general_options_parser.add_argument(
111 "--no-color",
112 action="store_true",
113 default=False,
114 help="Deactivate colored output",
115 )
116 parser = argparse.ArgumentParser(
117 description="Get python stack trace of a remote process",
118 )
119 parser.add_argument(
120 "-v", "--verbose", action="count", default=0, dest="global_verbose"
121 )
122 parser.add_argument(
123 "--version", action="version", version=__version__, help="Show version"
124 )
125 parser.add_argument(
126 "--no-color",
127 action="store_true",
128 dest="global_no_color",
129 help="Deactivate colored output",
130 )
131 parser.add_argument_group("command")
132 subparsers = parser.add_subparsers(
133 title="commands",
134 help="What should be analyzed by Pystack "
135 "(use <command> --help for a command-specific help section).",
136 dest="command",
137 )
138 subparsers.required = True
139 remote_parser = subparsers.add_parser(
140 "remote",
141 help="Analyze a remote process given its PID",
142 parents=[general_options_parser],
143 )
144 remote_parser.set_defaults(func=process_remote)
145 remote_parser.add_argument("pid", type=int, help="The PID of the remote process")
146 remote_parser.add_argument(
147 "--no-block",
148 dest="block",
149 action="store_false",
150 help="do not block the process when inspecting its memory",
151 )
152 remote_parser.add_argument(
153 "--native",
154 action="store_const",
155 dest="native_mode",
156 const=NativeReportingMode.PYTHON,
157 default=NativeReportingMode.OFF,
158 help="Include the native (C) frames in the resulting stack trace",
159 )
160 remote_parser.add_argument(
161 "--native-all",
162 action="store_const",
163 dest="native_mode",
164 const=NativeReportingMode.ALL,

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected