Build a Cross-Platform Web API CLI in 15 minutes with Mruby-CLI

Build a Cross-Platform Web API CLI in 15 minutes with Mruby-CLI

Thanks to web APIs, we can extend any web apps with simple Ruby CLI: listing open pull requests, or tweeting directly from the terminal.

Unfortunately, distributing Ruby CLIs is complicated. So many runtimes to support, so hard to guarantee compatibility of gems on every platforms.

With mruby-cli, you can easily build an API CLI in mruby, a Ruby sibbling, and distribute it for every major platforms.

In this talk, we'll show how quickly you can build and distribute a such CLI with mruby-cli.

GitHub Repository:
- mruby-cli https://github.com/hone/mruby-cli
- mruby-web_api https://travis-ci.org/toch/mruby-web_api
- github_status https://github.com/toch/github_status

Screencasts of the live coding made during the talk https://gfycat.com/tochgif/rubyconf_ph_2016

3f8fcddf7ab5d1bd90b0a0a9adfd6527?s=128

Christophe Philemotte

April 09, 2016
Tweet

Transcript

  1. 3.
  2. 4.
  3. 6.
  4. 7.
  5. 8.

    GitHub -> Hub Heroku -> Heroku Toolbelt AWS -> aws-cli

    Trello -> trello_cli Slack -> slack-cli ...
  6. 9.
  7. 12.
  8. 14.
  9. 15.
  10. 16.
  11. 17.
  12. 18.
  13. 19.
  14. 20.
  15. 22.
  16. 23.
  17. 24.
  18. 26.
  19. 27.
  20. 30.

    → Ruby → Performance → No Require → Binary for

    each platform/arch → Simple to compile & release → CLI apps framework Mruby-cli talk at RubyKaigi 2015 Goals
  21. 31.
  22. 32.
  23. 33.

    → ISO/IEC 30170:2012 standard → Compatible with Ruby 2.1 core

    API → No Built-in File/Socket/IO → not threadsafe, no Thread → procs/blocks → metaprogramming → monkey patching → literals → easy to bind to C-ABI compatible lib
  24. 34.

    Gotchas: → no stdlib → native ext have to support

    cross- compilation → no Rubygems, but mrbgems-list
  25. 35.
  26. 36.
  27. 37.