particle-iot/spark-cli

[Proposal] Use commander js to build the CLI interface

Closed this issue · 2 comments

Hello! I'm a happy owner of a Spark Core! :)

I have a proposal, but is a bit "disruptive". I'm proposing this because I think is a big improvement that could make contribution easier and because I'm willing to work on it.

First, my problem: after getting the Core I searched around the forum for a way to flash it via usb ( Spark Could is amazing, but doesn't suit my need in this case ). I'm on Ubuntu, and I've successfully installed the toolchain and compiled and flashed both tinker and the blink example. :) Nice and clean. Then I tough about making a PR to the cli to add command line compilation with a local toolchain, but I had a lot of trouble understanding how to create the command, make it work in parallel with compile which is mapped to cloud compile, understanding how to pass options, ...
Second, my proposal: would be possible to rewrite the command line using commander.js? Is a widely known and used tool for building CLI application, and I think that using such a widely used library would make contribution a lot easier. :)

I started working on this and you can find a proof of concept in my fork of the repository ( find it here ): look into bin and lib/commands. It's only a stub but the command line works ( obviously does not perform any action ).

Please, tell me your thoughts about it! :)

Hey @endorama!

Thank you for the idea and for being willing to put in the work on it. I'm certainly interested in anything that will help make it easier for people to use & contribute to our tools.

One thing to mention is that (unless I'm misunderstanding your needs), you can already flash the Core via USB, like so:

spark flash --usb <path to binary>

See here for more information: https://github.com/endorama/spark-cli#spark-flash

As for using something like Commander.js, I'm not necessarily opposed to the idea, but it's not something that feels like a high enough priority right now to take precedence over other things we're working on like support for the Photon.

My primary concern with the idea is that some of the things @dmiddlecamp has done make it super easy to customize, as well as making it a bit more user-friendly (particularly for folks that are new to command-line interfaces). I think to seriously entertain the idea of switching to something like commander, we would need to be able to provide similar functionality. One such feature is the way he's made it possible to 'map' commands. Take a look here.

If this seems like something you still want to take on, let's chat about it and see what we can decide about how to best implement such a large change! I'm sure @dmiddlecamp will have some thoughts too.

Let me know if you have any questions about local flashing as well! 😸

@endorama I thought you might like to know that we've since started using inquirer to improve upon the UX of the CLI. Check it out here: https://github.com/spark/particle-cli/ (also we've renamed the CLI tool!)