Skip to content

Commit ef8282c

Browse files
Josverldpgeorge
authored andcommitted
docs/reference/mpremote: Update docs for mpremote rm -r.
Signed-off-by: Jos Verlinde <[email protected]>
1 parent 72d4c40 commit ef8282c

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

docs/reference/mpremote.rst

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ The full list of supported commands are:
229229
- ``ls`` to list the current directory
230230
- ``ls <dirs...>`` to list the given directories
231231
- ``cp [-rf] <src...> <dest>`` to copy files
232-
- ``rm <src...>`` to remove files on the device
232+
- ``rm [-r] <src...>`` to remove files or folders on the device
233233
- ``mkdir <dirs...>`` to create directories on the device
234234
- ``rmdir <dirs...>`` to remove directories on the device
235235
- ``touch <file..>`` to create the files (if they don't already exist)
@@ -238,15 +238,35 @@ The full list of supported commands are:
238238
The ``cp`` command uses a convention where a leading ``:`` represents a remote
239239
path. Without a leading ``:`` means a local path. This is based on the
240240
convention used by the `Secure Copy Protocol (scp) client
241-
<https://en.wikipedia.org/wiki/Secure_copy_protocol>`_. All other commands
242-
implicitly assume the path is a remote path, but the ``:`` can be optionally
243-
used for clarity.
241+
<https://en.wikipedia.org/wiki/Secure_copy_protocol>`_.
244242

245243
So for example, ``mpremote fs cp main.py :main.py`` copies ``main.py`` from
246244
the current local directory to the remote filesystem, whereas
247245
``mpremote fs cp :main.py main.py`` copies ``main.py`` from the device back
248246
to the current directory.
249247

248+
The ``mpremote rm -r`` command accepts both relative and absolute paths.
249+
Use ``:`` to refer to the current remote working directory (cwd) to allow a
250+
directory tree to be removed from the device's default path (eg ``/flash``, ``/``).
251+
Use ``-v/--verbose`` to see the files being removed.
252+
253+
For example:
254+
255+
- ``mpremote rm -r :libs`` will remove the ``libs`` directory and all its
256+
child items from the device.
257+
- ``mpremote rm -rv :/sd`` will remove all files from a mounted SDCard and result
258+
in a non-blocking warning. The mount will be retained.
259+
- ``mpremote rm -rv :/`` will remove all files on the device, including any
260+
located in mounted vfs such as ``/sd`` or ``/flash``. After removing all folders
261+
and files, this will also return an error to mimic unix ``rm -rf /`` behaviour.
262+
263+
.. warning::
264+
There is no supported way to undelete files removed by ``mpremote rm -r :``.
265+
Please use with caution.
266+
267+
All other commands implicitly assume the path is a remote path, but the ``:``
268+
can be optionally used for clarity.
269+
250270
All of the filesystem sub-commands take multiple path arguments, so if there
251271
is another command in the sequence, you must use ``+`` to terminate the
252272
arguments, e.g.

tools/mpremote/tests/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,26 @@ This directory contains a set of tests for `mpremote`.
44

55
Requirements:
66
- A device running MicroPython connected to a serial port on the host.
7+
- The device you are testing against must be flashed with a firmware of the same build
8+
as `mpremote`.
9+
- If the device has an SDcard or other vfs mounted, the vfs's filesystem must be empty
10+
to pass the filesystem test.
711
- Python 3.x, `bash` and various Unix tools such as `find`, `mktemp`, `sed`, `sort`, `tr`.
12+
- To test on Windows, you can either:
13+
- Run the (Linux) tests in WSL2 against a USB device that is passed though to WSL2.
14+
- Use the `Git Bash` terminal to run the tests against a device connected to a COM
15+
port. _Note:_ While the tests will run in `Git Bash`, several will throw false
16+
positive errors due to differences in the way that TMP files are logged and and
17+
several other details.
818

919
To run the tests do:
1020

21+
$ cd tools/mpremote/tests
1122
$ ./run-mpremote-tests.sh
1223

24+
To run a single test do:
25+
26+
$ ./run-mpremote-tests.sh test_filesystem.sh
27+
1328
Each test should print "OK" if it passed. Otherwise it will print "CRASH", or "FAIL"
1429
and a diff of the expected and actual test output.

0 commit comments

Comments
 (0)