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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Mann
September 08, 2012
Programming
610
5
Share
Thor - Building CLI with ruby
Create command-line interface with thor
Mann
September 08, 2012
More Decks by Mann
See All by Mann
From Cambodia to Mizzou
lchanmann
0
41
Khmer ASR using Deep Learning
lchanmann
0
450
Path Finding using Search Algorithms
lchanmann
0
47
The secret to a good life
lchanmann
0
52
Monit - unix monitoring utility
lchanmann
1
110
Techcamp PP
lchanmann
0
110
Trying out Verboice
lchanmann
1
98
CoffeeScript
lchanmann
4
200
Other Decks in Programming
See All in Programming
Programming with a DJ Controller — not vibe coding
m_seki
3
850
[RubyKaigi 2026] Require Hooks
palkan
1
320
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
430
決定論 vs 確率論:Gemini 3 FlashとTF-IDFを組み合わせた「法規判定エンジン」の構築
shukob
0
160
空間オーディオの活用
objectiveaudio
0
150
【ディップ|26年新卒研修資料】TDD実装演習
dip_tech
PRO
0
180
Import assertionsが消えた日~ECMAScriptの仕様はどう決まり、なぜ覆るのか~
bicstone
2
180
2026年のソフトウェア開発を考える(2026/05版) / Software Engineering Scrum Fest Niigata 2026 Edition
twada
PRO
23
12k
t *testing.T は どこからやってくるの?
otakakot
1
940
GoogleCloudとterraform完全に理解した
terisuke
1
200
「OSSがあるなら自作するな」は AI時代も正しいか ── Build vs Adopt の新しい判断基準
kumorn5s
7
2.6k
書籍「ユーザーストーリーマッピング」が私のバイブル
asumikam
4
490
Featured
See All Featured
Optimizing for Happiness
mojombo
378
71k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
210
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
180
The untapped power of vector embeddings
frankvandijk
2
1.7k
Designing for Performance
lara
611
70k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9k
Ethics towards AI in product and experience design
skipperchong
2
270
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Designing for Timeless Needs
cassininazir
1
220
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
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