Skip to content

Commit 9bf1dc9

Browse files
committed
run Python REPL if no command is given to pdm run
Close pdm-project#856
1 parent df1afd6 commit 9bf1dc9

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

news/856.feature.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
If no command is given to `pdm run`, it will run the Python REPL.

pdm/cli/commands/run.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,12 @@ def handle(self, project: Project, options: argparse.Namespace) -> None:
211211
assert isinstance(global_env_options, dict)
212212
global_env_options.update(site_packages=options.site_packages)
213213
if not options.command:
214-
raise PdmUsageError("No command given")
214+
project.core.ui.echo(
215+
"No command is given, default to the Python REPL.",
216+
fg="yellow",
217+
err=True,
218+
)
219+
options.command = "python"
215220
if project.scripts and options.command in project.scripts:
216221
self._run_script(project, options.command, options.args, global_env_options)
217222
else:

0 commit comments

Comments
 (0)