Skip to content

Commit

Permalink
tools/mpremote: Print nicer errors for unsupported 'cp -r' arguments.
Browse files Browse the repository at this point in the history
Also document support for 'cp :a :b'.

Signed-off-by: Damien George <damien@micropython.org>
  • Loading branch information
dpgeorge committed Aug 26, 2022
1 parent f5fedf4 commit 2e386bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/reference/mpremote.rst
Expand Up @@ -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
7 changes: 6 additions & 1 deletion tools/mpremote/mpremote/main.py
Expand Up @@ -333,10 +333,15 @@ def _list_recursive(files, path):
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")
Expand Down

0 comments on commit 2e386bc

Please sign in to comment.