Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Making CLI app in ruby

Making CLI app in ruby

  • Be the first to comment

  • Be the first to like this

Making CLI app in ruby

  1. 1. Making CLI app with ruby
  2. 2. I'm Huy @huydx I'm software developer base in Tokyo, Japan Blogger at http://ktmt.github.io
  3. 3. What is CLI app • CLI stand for command-line interface • Some examples of CLI app Git $git log --UI --word-diff Grep $grep -c false /etc/passwd mysql-cli >mysql ruby-irb 2.1.3 :001 > 1 + 1 #2 single line shell interactive shell
  4. 4. Why making CLI app • We are programmers, we live in terminal • Good CLI tool make our life easier • Using terminal make us feel like a god
  5. 5. Introduce Thor erikhuda/thor "Thor is a simple and efficient tool for building self-documenting command line utilities." Using thor, we can build single command line app with ease
  6. 6. Let's make a simple THOR app (live coding)
  7. 7. But.....
  8. 8. Single line shell app is somewhat boring~~~
  9. 9. Let's make interactive shell app using REPL • REPL stands for read–eval–print loop • REPL can simply be a loop ! while (line=gets) do #do something with line end ! • Using REPL makes our app more interactive
  10. 10. Writing complex interactive shell from the scratch is hard...
  11. 11. Introduce Readline "The GNU Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in. " http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html GNU readline binding for ruby is a built in STL!!!!!!
  12. 12. What Readline capable of • Customize-able prompt!!! • Manage-able history • Auto completion • Interchange-able editing mode (vim, emacs)
  13. 13. Let's make a simple Readline app (live coding)
  14. 14. Some tips to make better CLI app • Do one thing • Playing well with Others (streams, exit code) • Have clear, concise purpose • Perfect documentation
  15. 15. FACY facebook command line app huydx.com/facy
  16. 16. This is how my app looks like
  17. 17. REPO AT HTTP://HUYDX.COM/FACY
  18. 18. Thank you for listening!!!

    Be the first to comment

    Login to see the comments

Making CLI app in ruby

Views

Total views

1,569

On Slideshare

0

From embeds

0

Number of embeds

27

Actions

Downloads

4

Shares

0

Comments

0

Likes

0

×