That looks really cool - it doesn't seem to handle multi-line editing yet though?
There's actually some simple autocomplete code in the Espruino Web IDE at the moment - as it's also JS I wonder if it can be shared... https://github.com/espruino/EspruinoWebIDE/blob/master/js/codemirror/addon/hint/espruino-hint.js
I intend to improve that quite a lot at some point (I'll export some data from build_docs.py in Espruino) so it'd be cool if your project could take advantage of that (or could help the Web IDE as well ;)
As it looks like you're caching the whole JS command before sending it to Espruino, syntax highlighting would be awesome :)
I've been looking at Node's repl module to add multi-line support, sophisticated auto-complete, and load/save.
I've been trying to figure out how to mask the repl context so that Node's built-ins which aren't present in Espruino don't get exposed. I'm making some progress there but it would be awesome to get a full mock representation of Espruino in order to support property and method completion (I guess that's where the py script comes in).
Btw, would it be ok with you if I publish this to npm as espruino-cli so that it's easy to find? If so I might still keep the bin as esp-cli.
Publishing to npm would be great - it'd be great to be able to give people easier steps to get it!
As far as getting that list of builtins, it might be easier to just copy the JSON directly from source files and let you do what you need with it. For instance:
There's some documentation on the format here: https://github.com/espruino/Espruino/blob/master/scripts/common.py#L32
Using the JSON schemas definitely looks feasible. I'll dig in and try to generate a stub Espruino for autocomplete. It will be my first time in Python but I've always heard good things. :D
Thanks! Take a look at build_docs.py or build_jswrapper.py - common.py has code to read in all the json data, then you should just need to call something like:
print(json.dumps(mydata))and it'll dump it all out.
Thanks for merging the PRs Gordon! This is now published and can be installed with:
npm i -g espruino-cli
After install it can be executed with:
Currently only the original Espruino board and the STM32 series are detected but other devices are easily added. Please paste the output of the "Analyzing" line if you have an Espruino supported board that is not properly detected.
Other issues or requests can be filed at:
The CLI has been updated with the following features:
- Support loading of modules via the
.modulecommand (from espruino.com, url, or local file)
- Implement buffer to work around Espruino lost character issues
- Support loading of modules via the
This is awesome!
I just posted a topic here: http://forum.espruino.com/conversations/1642/ to say hi and thank you to Gordon. Hi and thank you to you too!
I forked your repo here: https://github.com/ARMinARM/esp-cli/tree/arminarm (you may have already seen that on your github dashboard).
Notice how I had to hack around a little, to make esp-cli recognize /dev/ttyAMA0. I basically changed the search for available serial ports to 'connect('/dev/ttyAMA0');'. I never thought that was going to work, but it did and here we are :-)
Is there a way to stay closer to your original version, and add '/dev/ttyAMA0' to a search path or some such? I didn't find that where I was looking for it (obviously the wrong place).
For you as well; if you think I somehow misrepresented you, please let me know (also check the Espruino page on http://www.onandoffables.com).
I've started a command line interface here:
Currently it attempts to detect the port and connect automatically. Basic auto complete is also implemented (I'm thinking about adding the full Espruino API). So far it's only tested with the STM32F4Discovery on Linux. Hopefully it will get more useful over time.