minor fixes
This commit is contained in:
+5
-6
@@ -28,8 +28,6 @@ The application entry point is responsible for defining the command names. Once
|
|||||||
invalid input, and invokes the selected module's ``scott_run(args)`` function.
|
invalid input, and invokes the selected module's ``scott_run(args)`` function.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sys.dont_write_bytecode = True
|
|
||||||
|
|
||||||
class Scott:
|
class Scott:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -71,7 +69,7 @@ class Scott:
|
|||||||
scott_run = getattr(module, "scott_run", None)
|
scott_run = getattr(module, "scott_run", None)
|
||||||
if not callable(scott_run):
|
if not callable(scott_run):
|
||||||
print(
|
print(
|
||||||
f"Warning: Script {cmd_name}.py is missing a scott_run() function, skipping registration.",
|
f"Warning: ({cmd_name}) missing a scott_run() function, skipping registration.",
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@@ -81,7 +79,7 @@ class Scott:
|
|||||||
parameter_count = 0
|
parameter_count = 0
|
||||||
if parameter_count != 1:
|
if parameter_count != 1:
|
||||||
print(
|
print(
|
||||||
f"Warning: Script {cmd_name}.py scott_run() must take exactly one argument, skipping registration.",
|
f"Warning: ({cmd_name}) scott_run() must take exactly one argument, skipping registration.",
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@@ -93,13 +91,14 @@ class Scott:
|
|||||||
subparser = self.subparsers.add_parser(
|
subparser = self.subparsers.add_parser(
|
||||||
cmd_name,
|
cmd_name,
|
||||||
help = module.scott_description() if hasattr(module, "scott_description") else None,
|
help = module.scott_description() if hasattr(module, "scott_description") else None,
|
||||||
|
formatter_class=argparse.RawTextHelpFormatter
|
||||||
)
|
)
|
||||||
self.subparsers_by_command[cmd_name] = subparser
|
self.subparsers_by_command[cmd_name] = subparser
|
||||||
if hasattr(module, "scott_arguments"):
|
if hasattr(module, "scott_arguments"):
|
||||||
module.scott_arguments(subparser)
|
module.scott_arguments(subparser)
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError as error:
|
||||||
print(
|
print(
|
||||||
f"Warning: Script {cmd_name}.py not found, skipping registration.",
|
f"Warning: ({cmd_name}) Error loading command script\n{error}\nskipping registration.",
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user