Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Thor - Building CLI with ruby
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Mann
September 08, 2012
Programming
5
590
Thor - Building CLI with ruby
Create command-line interface with thor
Mann
September 08, 2012
Tweet
Share
More Decks by Mann
See All by Mann
From Cambodia to Mizzou
lchanmann
0
38
Khmer ASR using Deep Learning
lchanmann
0
430
Path Finding using Search Algorithms
lchanmann
0
46
The secret to a good life
lchanmann
0
44
Monit - unix monitoring utility
lchanmann
1
110
Techcamp PP
lchanmann
0
110
Trying out Verboice
lchanmann
1
95
CoffeeScript
lchanmann
4
200
Other Decks in Programming
See All in Programming
CSC307 Lecture 07
javiergs
PRO
0
550
ぼくの開発環境2026
yuzneri
0
170
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
180
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
170
Lambda のコードストレージ容量に気をつけましょう
tattwan718
0
110
CSC307 Lecture 05
javiergs
PRO
0
500
組織で育むオブザーバビリティ
ryota_hnk
0
170
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
160
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
140
CSC307 Lecture 06
javiergs
PRO
0
680
IFSによる形状設計/デモシーンの魅力 @ 慶應大学SFC
gam0022
1
300
Oxlint JS plugins
kazupon
1
850
Featured
See All Featured
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
180
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
0
310
WCS-LA-2024
lcolladotor
0
450
New Earth Scene 8
popppiees
1
1.5k
Designing for Timeless Needs
cassininazir
0
130
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
196
71k
Chasing Engaging Ingredients in Design
codingconduct
0
110
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
160
From π to Pie charts
rasagy
0
120
A better future with KSS
kneath
240
18k
KATA
mclloyd
PRO
34
15k
The Cult of Friendly URLs
andyhume
79
6.8k
Transcript
Building command-line interface (CLI) with ruby
I have learnt ruby the rails way. http://www.frankwatching.com/wordpress/wp-content/uploads/2007/11/rails.jpg
Then... tryruby.org rubykoans.com rubeque.com more and more ruby
A rails app is a ruby app. A ruby app
may NOT be a rails app.
Today Ruby on CLI
What for? Utility => curl Code Genertor => Rails generator
Automation => db migration
Hello world puts "Hello world"
My ideal CLI mycli <command> [options]
I need to parse the command and options in mycli
manually. ARGV or
None
Multiple commands desc "hi", "Say hi" def hi puts "hi
!" end desc "bye", "Say goodbye" def bye puts "bye !" end
Passing argument desc "hello NAME", "Say hello to <NAME>" def
hello(name) puts "hello #{name}!" end
Parsing options desc "hello NAME", "Say hello to <NAME>" method_options
loudly: false def hello(name) name.upcase! if options[:loudly] puts "hello #{name}!" end
Documentation ready
Thanks @lchanmann
References http://whatisthor.com/ http://yehudakatz.com/2009/01/13/some-thor-news/ http://rubylearning.com/blog/2011/01/03/how-do-i-make-a-command-line-tool-in-ruby/ http://www.bounga.org/ruby/2011/09/12/thor-a-command-line-scripting-tool/ Demo: https://gist.github.com/3688473 Checkout thor on
Github https://github.com/wycats/thor http://whatisthor.com/images/thor.png