tools/mpremote: Allow + terminator for fs commands.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
parent
8f4c108025
commit
a311e9e3d4
|
@ -30,6 +30,9 @@ For REPL access, running ``mpremote`` without any arguments is usually all that
|
||||||
is needed. ``mpremote`` also supports a set of commands given at the command
|
is needed. ``mpremote`` also supports a set of commands given at the command
|
||||||
line which will perform various actions on remote MicroPython devices.
|
line which will perform various actions on remote MicroPython devices.
|
||||||
|
|
||||||
|
For commands that support multiple arguments (e.g. a list of files), the
|
||||||
|
argument list can be terminated with ``+``.
|
||||||
|
|
||||||
The full list of supported commands are:
|
The full list of supported commands are:
|
||||||
|
|
||||||
- connect to a specified device via a device-name shortcut:
|
- connect to a specified device via a device-name shortcut:
|
||||||
|
@ -248,3 +251,5 @@ Examples
|
||||||
mpremote cp main.py :
|
mpremote cp main.py :
|
||||||
|
|
||||||
mpremote cp -r dir/ :
|
mpremote cp -r dir/ :
|
||||||
|
|
||||||
|
mpremote cp a.py b.py : + repl
|
||||||
|
|
|
@ -300,6 +300,19 @@ def show_progress_bar(size, total_size):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Get all args up to the terminator ("+").
|
||||||
|
# The passed args will be updated with these ones removed.
|
||||||
|
def get_fs_args(args):
|
||||||
|
n = 0
|
||||||
|
for src in args:
|
||||||
|
if src == "+":
|
||||||
|
break
|
||||||
|
n += 1
|
||||||
|
fs_args = args[:n]
|
||||||
|
args[:] = args[n + 1 :]
|
||||||
|
return fs_args
|
||||||
|
|
||||||
|
|
||||||
def do_filesystem(pyb, args):
|
def do_filesystem(pyb, args):
|
||||||
def _list_recursive(files, path):
|
def _list_recursive(files, path):
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
|
@ -308,16 +321,18 @@ def do_filesystem(pyb, args):
|
||||||
else:
|
else:
|
||||||
files.append(os.path.split(path))
|
files.append(os.path.split(path))
|
||||||
|
|
||||||
# Don't be verbose when using cat, so output can be redirected to something.
|
fs_args = get_fs_args(args)
|
||||||
verbose = args[0] != "cat"
|
|
||||||
|
|
||||||
if args[0] == "cp" and args[1] == "-r":
|
# Don't be verbose when using cat, so output can be redirected to something.
|
||||||
args.pop(0)
|
verbose = fs_args[0] != "cat"
|
||||||
args.pop(0)
|
|
||||||
assert args[-1] == ":"
|
if fs_args[0] == "cp" and fs_args[1] == "-r":
|
||||||
args.pop()
|
fs_args.pop(0)
|
||||||
|
fs_args.pop(0)
|
||||||
|
assert fs_args[-1] == ":"
|
||||||
|
fs_args.pop()
|
||||||
src_files = []
|
src_files = []
|
||||||
for path in args:
|
for path in fs_args:
|
||||||
_list_recursive(src_files, path)
|
_list_recursive(src_files, path)
|
||||||
known_dirs = {""}
|
known_dirs = {""}
|
||||||
pyb.exec_("import uos")
|
pyb.exec_("import uos")
|
||||||
|
@ -335,8 +350,9 @@ def do_filesystem(pyb, args):
|
||||||
verbose=verbose,
|
verbose=verbose,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
pyboard.filesystem_command(pyb, args, progress_callback=show_progress_bar, verbose=verbose)
|
pyboard.filesystem_command(
|
||||||
args.clear()
|
pyb, fs_args, progress_callback=show_progress_bar, verbose=verbose
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def do_repl_main_loop(pyb, console_in, console_out_write, *, code_to_inject, file_to_inject):
|
def do_repl_main_loop(pyb, console_in, console_out_write, *, code_to_inject, file_to_inject):
|
||||||
|
|
Loading…
Reference in New Issue