tools/mpremote: Print nicer errors for unsupported 'cp -r' arguments.

Also document support for 'cp :a :b'.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2022-08-24 10:33:11 +10:00
parent f5fedf4676
commit 2e386bcf76
2 changed files with 8 additions and 1 deletions

View File

@ -262,6 +262,8 @@ Examples
mpremote cp main.py :
mpremote cp :a.py :b.py
mpremote cp -r dir/ :
mpremote cp a.py b.py : + repl

View File

@ -333,10 +333,15 @@ def do_filesystem(pyb, args):
if fs_args[0] == "cp" and fs_args[1] == "-r":
fs_args.pop(0)
fs_args.pop(0)
assert fs_args[-1] == ":"
if fs_args[-1] != ":":
print(f"{_PROG}: 'cp -r' destination must be ':'")
sys.exit(1)
fs_args.pop()
src_files = []
for path in fs_args:
if path.startswith(":"):
print(f"{_PROG}: 'cp -r' source files must be local")
sys.exit(1)
_list_recursive(src_files, path)
known_dirs = {""}
pyb.exec_("import uos")