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
35
Khmer ASR using Deep Learning
lchanmann
0
370
Path Finding using Search Algorithms
lchanmann
0
35
The secret to a good life
lchanmann
0
41
Monit - unix monitoring utility
lchanmann
1
110
Techcamp PP
lchanmann
0
110
Trying out Verboice
lchanmann
1
86
CoffeeScript
lchanmann
4
200
Other Decks in Programming
See All in Programming
ComposeでWebアプリを作る技術
tbsten
0
110
Memory API : Patterns, Performance et Cas d'Utilisation
josepaumard
0
120
Unlock the Potential of Swift Code Generation
rockname
0
250
リアルタイムレイトレーシング + ニューラルレンダリング簡単紹介 / Real-Time Ray Tracing & Neural Rendering: A Quick Introduction (2025)
shocker_0x15
1
300
「”誤った使い方をすることが困難”な設計」で良いコードの基礎を固めよう / phpcon-odawara-2025
taniguhey
0
130
5年間継続して開発した自作OSSの記録
bebeji_nappa
0
190
AI Coding Agent Enablement - エージェントを自走させよう
yukukotani
14
6k
Making TCPSocket.new "Happy"!
coe401_
1
430
AHC045_解説
shun_pi
0
520
海外のアプリで見かけたかっこいいTransitionを真似てみる
shogotakasaki
1
170
SQL Server ベクトル検索
odashinsuke
0
170
小田原でみんなで一句詠みたいな #phpcon_odawara
stefafafan
0
320
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
329
38k
The Cost Of JavaScript in 2023
addyosmani
49
7.7k
Fontdeck: Realign not Redesign
paulrobertlloyd
83
5.5k
Scaling GitHub
holman
459
140k
Visualization
eitanlees
146
16k
Designing for Performance
lara
607
69k
Building Adaptive Systems
keathley
41
2.5k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Documentation Writing (for coders)
carmenintech
69
4.7k
The World Runs on Bad Software
bkeepers
PRO
67
11k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
5
530
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
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