Add better inspector arg parsing (#2642)
This commit is contained in:
@@ -148,8 +148,17 @@ Or, a path to a directory to run as a simple HTTP server:
|
||||
if unknown:
|
||||
for arg in unknown:
|
||||
if arg.startswith("--"):
|
||||
key, value = arg.split("=")
|
||||
setattr(self.args, key.lstrip("-"), value)
|
||||
try:
|
||||
key, value = arg.split("=")
|
||||
key = key.lstrip("-")
|
||||
except ValueError:
|
||||
value = False if arg.startswith("--no-") else True
|
||||
key = (
|
||||
arg.replace("--no-", "")
|
||||
.lstrip("-")
|
||||
.replace("-", "_")
|
||||
)
|
||||
setattr(self.args, key, value)
|
||||
|
||||
kwargs = {**self.args.__dict__}
|
||||
host = kwargs.pop("host")
|
||||
|
||||
@@ -47,11 +47,16 @@ def make_inspector_parser(parser: ArgumentParser) -> None:
|
||||
action=SanicSubParsersAction,
|
||||
dest="action",
|
||||
description=(
|
||||
"Run one of the below subcommands. If you have created a custom "
|
||||
"Inspector instance, then you can run custom commands. See ___ "
|
||||
"Run one or none of the below subcommands. Using inspect without "
|
||||
"a subcommand will fetch general information about the state "
|
||||
"of the application instance.\n\n"
|
||||
"Or, you can optionally follow inspect with a subcommand. "
|
||||
"If you have created a custom "
|
||||
"Inspector instance, then you can run custom commands. See "
|
||||
"https://sanic.dev/en/guide/deployment/inspector.html"
|
||||
"for more details."
|
||||
),
|
||||
title="Required\n========\n Subcommands",
|
||||
title=" Subcommands",
|
||||
parser_class=InspectorSubParser,
|
||||
)
|
||||
reloader = subparsers.add_parser(
|
||||
|
||||
Reference in New Issue
Block a user