Skip to content

khalidbelk/microCLI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MicroCLI πŸ”Œ

This project was built to facilitate the process of interacting directly with your BBC micro:bit's MicroPython filesystem without tools like MakeCode or Python Editor. It's built on top of Microfs, which has made the process easier.

Requirements

  • Python 3.11

Usage

Install dependencies with :

pip install -r requirements.txt

Execute the command:

  make

Use the program like this:

./microCLI [-ls | -up | -save | -rm | -rename |Β -show |Β -v | --version | -h |Β --help] <FILENAME> <NEWNAME>
DESCRIPTION:

    ./microCLI                      : run your main.py file on the micro:bit. The file should be located at the root (same level as the microCLI).

    -h | --help                     : display this message and exit.
    -ls                             : show the files currently on the micro:bit filesystem.
    -up <FILENAME> <NEWNAME>        : upload a specific file into the micro:bit. Needs the path of the source file. Accepts an optional argument to name the file you want to upload differently.
    -save <FILENAME> <NEWNAME>      : save a file from the micro:bit to your device. The file name is required. You can optionally specify a new name for the file you want to save.
    -rm <FILENAME>                  : delete a file from the micro:bit.
    -rename <FILENAME> <NEWNAME>    : renames a file directly into the micro:bit. Needs the name of the file you want to rename and the new name. E.g.: -rename hello.py main.py
    -show <FILENAME>                : show the content of a file on the micro:bit (similar to Unix 'cat' command)
    -v | --version                  : shows the MicroPython version and some information about the connected micro:bit

Why ?

I was looking for a way to test stuff directly on my micro:bit. After doing some research, I found out that there weren't many options to run Python code on it, aside from the MakeCode / Python Editor online tools. I eventually found a VS Code extension that did the job, but having to use the command palette to navigate every couple of minutes was a hassle (search for the right text to click on...etc), then I found out it was using MicroFS under the hood, so I thought that would be a good starting point to create an easy way to test my code via terminal. While MicroFS is solid, the original repository was not so user-friendly for someone who would just like to quickly run his code into the device, since it's more focused on its pip package 'ufs', which is understandable, but I wanted something more straightforward and simpler.

So I decided to create something that would suit my needs and make it simpler for others who might be in the same situation.

Main advantages:

  • Quick Setup: Use a Makefile to build the CLI executable, focusing only on the commands you need.
  • Easy Testing: Apply changes directly to your micro:bit's main.py file with a single command: ./microCLI
  • More intuitive usage & enhanced message.
  • More recent & maintained.
  • Includes additional features such as file renaming and file content display (maybe more to be added).

About

An easy-to-understand command line tool for the BBC micro:bit πŸ”Œ

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published