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
36
Khmer ASR using Deep Learning
lchanmann
0
390
Path Finding using Search Algorithms
lchanmann
0
41
The secret to a good life
lchanmann
0
42
Monit - unix monitoring utility
lchanmann
1
110
Techcamp PP
lchanmann
0
110
Trying out Verboice
lchanmann
1
89
CoffeeScript
lchanmann
4
200
Other Decks in Programming
See All in Programming
GPUを計算資源として使おう!
primenumber
1
290
NEWT Backend Evolution
xpromx
1
150
テスト駆動Kaggle
isax1015
1
880
なぜあなたのオブザーバビリティ導入は頓挫するのか
ryota_hnk
2
370
Claude Code派?Gemini CLI派? みんなで比較LT会!_20250716
junholee
1
700
副作用と戦う PHP リファクタリング ─ ドメインイベントでビジネスロジックを解きほぐす
kajitack
2
440
ISUCON研修おかわり会 講義スライド
arfes0e2b3c
1
480
TypeScriptでDXを上げろ! Hono編
yusukebe
3
860
MDN Web Docs に日本語翻訳でコントリビュートしたくなる
ohmori_yusuke
1
130
SwiftでMCPサーバーを作ろう!
giginet
PRO
2
190
CDK引数設計道場100本ノック
badmintoncryer
2
560
顧客の画像データをテラバイト単位で配信する 画像サーバを WebP にした際に起こった課題と その対応策 ~継続的な取り組みを添えて~
takutakahashi
4
1.4k
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
850
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
KATA
mclloyd
30
14k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
370
How STYLIGHT went responsive
nonsquared
100
5.6k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.5k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
Unsuck your backbone
ammeep
671
58k
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