rp-cli: Rust Playground CLI
I built rp-cli. rp-cli is the CLI tool of Rust Playground. You are able to use Rust Playground in your Terminal without opening a browser.
Motivation
Again, I wanted to use Rust Playground without opening a browser. In other words, I wanted to write Rust using my Vim editor and then use Rust Playground in that local file. Also i was inspired by tenntenn/goplayground. Finally, the most motivation is learning the Rust!
Installation
$ cargo install rp-cli
Features
Following is introducing rp-cli’s features.
run
run command results are output to Stdout and Stderr.
run
command supports the edition
, channel
, mode
, etc.
OPTIONS:
--backtrace <BACKTRACE> [default: false]
--channel <CHANNEL> [default: stable]
--edition <EDITION> [default: 2021]
-h, --help Print help information
--mode <MODE> [default: debug]
format
share
Output “Permalink to the playground” and “Direct link to the gist”. Not supporting ”Embedded code in link” and “Open a new thread in the Rust user forum”.
download
Output Rust code. Also supporting gist_id or full playground url.
Internal
cli Interface
Using clap to parse CLI args.
API/Output
By using reqwest and serde, rp-cli handle API request/response. At last, it’s output to Stdout.
TODO
If possible, i would like to support other run type (build, test, wasm…), out to file, output JSON format. Also i want to clean the rust code.
Conclusion
Although the code is not pretty, i was able to build a Rust CLI tool.
Enjoy Rust!