Skip to content

Commit 2e386bc

Browse files
committed
tools/mpremote: Print nicer errors for unsupported 'cp -r' arguments.
Also document support for 'cp :a :b'. Signed-off-by: Damien George <[email protected]>
1 parent f5fedf4 commit 2e386bc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

docs/reference/mpremote.rst

+2
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ Examples
262262
263263
mpremote cp main.py :
264264
265+
mpremote cp :a.py :b.py
266+
265267
mpremote cp -r dir/ :
266268
267269
mpremote cp a.py b.py : + repl

tools/mpremote/mpremote/main.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,15 @@ def _list_recursive(files, path):
333333
if fs_args[0] == "cp" and fs_args[1] == "-r":
334334
fs_args.pop(0)
335335
fs_args.pop(0)
336-
assert fs_args[-1] == ":"
336+
if fs_args[-1] != ":":
337+
print(f"{_PROG}: 'cp -r' destination must be ':'")
338+
sys.exit(1)
337339
fs_args.pop()
338340
src_files = []
339341
for path in fs_args:
342+
if path.startswith(":"):
343+
print(f"{_PROG}: 'cp -r' source files must be local")
344+
sys.exit(1)
340345
_list_recursive(src_files, path)
341346
known_dirs = {""}
342347
pyb.exec_("import uos")

0 commit comments

Comments
 (0)