This is a very simple command line interface written in micropython. It's main purpose is to serve as a terminal interface to perform filesystem and diagnostic operations on a mounted drive that is connected to your microcontroller. The formatting this app uses is only properly supported by a linux terminal. Windows will understand the formatting, but interpret it differently. If you would like to retheme the interface it can be done easily by modifying lines 29 through 34. There are also some alternate theme ideas at the bottom of this repo.
If you are using a mounted drive with a Raspberry Pi Pico maybe you would be interested in my pico-sd-card module. This cli app was 100% written because of my SD card module, and my desire to be able to interact with the card, directly from the Pico, in a more graphical way. Using the loading external scripts example under Usage as a base, you could actually put this cli app on the SD card and run it from there.
To officially file a bug report or feature request you can use these templates: bug report | feature request
To discus features, bugs or share your own project that utilize code in this repo: join the discussion
This can be uploaded directly to the board, but is intended to be used as a frozen module. For information regarding how to setup the sdk and freeze a module you can refer to this post on the Raspberry Pi forum.
This is a cross-compiled version of
cli.py
. It is intended to be uploaded to your board as you would any normal.py
script.
CLI(clear
, user
)
Arg | Type | Description | Default |
---|---|---|---|
clear | bool | clears the terminal on startup | True |
user | str | personalize user@sysname:~/ |
'user' |
Whereas the
Same As
section of the below table is accurate, very few commands are identical to their equivalent. This is because returned information has formatting, sorting and/or pruning applied, and may trigger another command as a convenience.
Cmd | Description | Examples | Equivalent |
---|---|---|---|
exit | exit the CLI | no equivalent | |
help | prints this help info | no equivalent | |
clr | clear the terminal | print('\n'*100) |
|
now | prints system timestamp | utime.localtime(utime.time()) |
|
sysinfo | prints system info | no equivalent | |
collect | run garbage collection | gc.collect() |
|
list | lists the current directory | list [path] | uos.listdir() (sorted) |
cd | change directory | cd path | uos.chdir() |
print requested file | print fileName [r, rb] | no equivalent | |
mkdir | creates a new directory | mkdir dirName | uos.mkdir() |
del | delete a file or folder | del fileOrDirName | no equivalent |
rename | rename a file | rename oldname newname | uos.rename() |
find | find all with term from cwd | find term | no equivalent |
syspath | print or [modify] syspath | syspath [add, del] | sys.path [.append() , .remove() ] |
copy | copy a file | copy source dest [w, wb] | no equivalent |
cd
,mkdir
,del
andrename
will automatically list the targeted directory when their operation completessypath
will automatically list all paths when anadd
ordel
operation completescopy
will automatically list the parent directory of the destination file when the operation completes/absolute/path
,relative/path
, and../relative path
are all supported- wrap paths that contain spaces in quotes
'path/with space/file name.ext'
- most operations can be performed from anywhere as long as the path argument(s) are correct
del
is nuclear! It is the equivalent ofsudo rm -r mydir
. You will not be asked if you are sure.
simple
from cli import CLI
CLI(user='yourName') #auto-clears
from cli import CLI
CLI(False, 'yourName') #wont auto-clear
on button release
from cli import CLI
from machine import Pin
cli = Pin(3, Pin.IN, Pin.PULL_DOWN)
cli.irq(lambda p:CLI(user="yourName"), Pin.IRQ_FALLING) #on release
Here are a few alternate themes that can be copy/pasted over lines 29 through 34. I don't take the below themes very seriously, They are provided more so you can understand how each property affects the appearance, and easily make a theme that you like. Themes, in general, were never intended to be a feature. The way I programmed this made it very simple to change the appearance. Due to it's simplicity I decided to share the method. If you create an interesting theme share it here so others can enjoy it.
These images are from an older version and do not reflect the current feature-set that is available. The main image for this repository is always current. Formatting has not changed, and all of these themes are still relevant.
_MAIN = _FG_BLACK
_BRIGHT_FG = _FG_YELLOW
_FG = _FG_BLACK
_BG = _BG_RED
_ALT_FG = _FG_RED
_ALT_BG = _BG_BLACK
_MAIN = _FG_MAGENTA
_BRIGHT_FG = _FG_YELLOW
_FG = _FG_BLACK
_BG = _BG_GREEN
_ALT_FG = _FG_GREEN
_ALT_BG = _BG_BLACK
_MAIN = _FG_WHITE
_BRIGHT_FG = _FG_BLUE
_FG = _FG_WHITE
_BG = _BG_BLUE
_ALT_FG = _FG_WHITE
_ALT_BG = _BG_BLACK
_MAIN = _FG_WHITE
_BRIGHT_FG = _FG_WHITE
_FG = _FG_WHITE
_BG = _BG_BLACK
_ALT_FG = _FG_WHITE
_ALT_BG = _BG_BLACK
_MAIN = _FG_CYAN
_BRIGHT_FG = _FG_YELLOW
_FG = _FG_BLACK
_BG = _BG_MAGENTA
_ALT_FG = _FG_GREEN
_ALT_BG = _BG_BLACK