Skip to content

Commit 8d882f5

Browse files
committed
Renamed pyscript to run_pyscript
1 parent efe5310 commit 8d882f5

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

cmd2/cmd2.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3241,16 +3241,21 @@ def py_quit():
32413241

32423242
return bridge.stop
32433243

3244-
pyscript_parser = ACArgumentParser()
3245-
setattr(pyscript_parser.add_argument('script_path', help='path to the script file'),
3244+
run_pyscript_parser = ACArgumentParser()
3245+
setattr(run_pyscript_parser.add_argument('script_path', help='path to the script file'),
32463246
ACTION_ARG_CHOICES, ('path_complete',))
3247-
setattr(pyscript_parser.add_argument('script_arguments', nargs=argparse.REMAINDER,
3248-
help='arguments to pass to script'),
3247+
setattr(run_pyscript_parser.add_argument('script_arguments', nargs=argparse.REMAINDER,
3248+
help='arguments to pass to script'),
32493249
ACTION_ARG_CHOICES, ('path_complete',))
32503250

3251-
@with_argparser(pyscript_parser)
3252-
def do_pyscript(self, args: argparse.Namespace) -> bool:
3251+
@with_argparser(run_pyscript_parser)
3252+
def do_run_pyscript(self, args: argparse.Namespace) -> bool:
32533253
"""Run a Python script file inside the console"""
3254+
if args.__statement__.command == "pyscript":
3255+
self.perror("pyscript has been renamed and will be removed in the next release, "
3256+
"please use run_pyscript instead\n",
3257+
traceback_war=False, err_color=Fore.LIGHTYELLOW_EX)
3258+
32543259
script_path = os.path.expanduser(args.script_path)
32553260
py_return = False
32563261

@@ -3274,6 +3279,9 @@ def do_pyscript(self, args: argparse.Namespace) -> bool:
32743279

32753280
return py_return
32763281

3282+
# pyscript is deprecated
3283+
do_pyscript = do_run_pyscript
3284+
32773285
# Only include the do_ipy() method if IPython is available on the system
32783286
if ipython_available: # pragma: no cover
32793287
@with_argparser(ACArgumentParser())
@@ -3647,7 +3655,7 @@ def do_run_script(self, args: argparse.Namespace) -> Optional[bool]:
36473655
:return: True if running of commands should stop
36483656
"""
36493657
if args.__statement__.command == "load":
3650-
self.perror("load has been renamed and will be removed in the next release,"
3658+
self.perror("load has been renamed and will be removed in the next release, "
36513659
"please use run_script instead\n",
36523660
traceback_war=False, err_color=Fore.LIGHTYELLOW_EX)
36533661

0 commit comments

Comments
 (0)