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
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
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
250
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
180
Patterns of Patterns
denyspoltorak
0
1.4k
Oxlintはいいぞ
yug1224
5
1.3k
IFSによる形状設計/デモシーンの魅力 @ 慶應大学SFC
gam0022
1
300
プロダクトオーナーから見たSOC2 _SOC2ゆるミートアップ#2
kekekenta
0
200
Data-Centric Kaggle
isax1015
2
760
AI前提で考えるiOSアプリのモダナイズ設計
yuukiw00w
0
220
AIエージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
4
310
Spinner 軸ズレ現象を調べたらレンダリング深淵に飲まれた #レバテックMeetup
bengo4com
1
230
今から始めるClaude Code超入門
448jp
7
8.4k
2026年 エンジニアリング自己学習法
yumechi
0
130
Featured
See All Featured
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
79
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
We Are The Robots
honzajavorek
0
160
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
730
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
110
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
320
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
170
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