mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-16 15:29:56 +00:00
add exec to shell subcommand
This commit is contained in:
@ -762,6 +762,7 @@ def _set_shell_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||
parser = root.add_parser("shell", help="envoke python shell",
|
||||
description="drop into python shell while having created application",
|
||||
formatter_class=_formatter)
|
||||
parser.add_argument("code", help="instead of dropping into shell, just execute the specified code", nargs="?")
|
||||
parser.add_argument("-v", "--verbose", help=argparse.SUPPRESS, action="store_true")
|
||||
parser.set_defaults(handler=handlers.Shell, lock=None, report=False)
|
||||
return parser
|
||||
|
@ -56,4 +56,7 @@ class Shell(Handler):
|
||||
# licensed by https://creativecommons.org/licenses/by-sa/3.0
|
||||
path = Path(sys.prefix) / "share" / "ahriman" / "templates" / "shell"
|
||||
StringPrinter(path.read_text(encoding="utf8")).print(verbose=False)
|
||||
code.interact(local=locals())
|
||||
if args.code is None:
|
||||
code.interact(local=locals())
|
||||
else:
|
||||
code.InteractiveConsole(locals=locals()).runcode(args.code)
|
||||
|
Reference in New Issue
Block a user