From 2e386bcf76c38a81a9de93452f9a253c571d2b72 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 24 Aug 2022 10:33:11 +1000 Subject: [PATCH] tools/mpremote: Print nicer errors for unsupported 'cp -r' arguments. Also document support for 'cp :a :b'. Signed-off-by: Damien George --- docs/reference/mpremote.rst | 2 ++ tools/mpremote/mpremote/main.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/reference/mpremote.rst b/docs/reference/mpremote.rst index eb0233bdda..a48df9953f 100644 --- a/docs/reference/mpremote.rst +++ b/docs/reference/mpremote.rst @@ -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 diff --git a/tools/mpremote/mpremote/main.py b/tools/mpremote/mpremote/main.py index fa4785b3bf..bd98da8824 100644 --- a/tools/mpremote/mpremote/main.py +++ b/tools/mpremote/mpremote/main.py @@ -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")