Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
37
Khmer ASR using Deep Learning
lchanmann
0
420
Path Finding using Search Algorithms
lchanmann
0
45
The secret to a good life
lchanmann
0
43
Monit - unix monitoring utility
lchanmann
1
110
Techcamp PP
lchanmann
0
110
Trying out Verboice
lchanmann
1
93
CoffeeScript
lchanmann
4
200
Other Decks in Programming
See All in Programming
Level up your Gemini CLI - D&D Style!
palladius
1
140
FlutterKaigi 2025 システム裏側
yumnumm
0
1.2k
Reactive Thinking with Signals and the new Resource API
manfredsteyer
PRO
0
130
GeistFabrik and AI-augmented software development
adewale
PRO
0
220
チーム開発の “地ならし"
konifar
8
6.4k
2025 컴포즈 마법사
jisungbin
0
160
Micro Frontendsで築いた 共通基盤と運用の試行錯誤 / Building a Shared Platform with Micro Frontends: Operational Learnings
kyntk
1
1.6k
Feature Flags Suck! - KubeCon Atlanta 2025
phodgson
1
190
CSC305 Lecture 15
javiergs
PRO
0
210
関数実行の裏側では何が起きているのか?
minop1205
1
240
「文字列→日付」の落とし穴 〜Ruby Date.parseの意外な挙動〜
sg4k0
0
320
GraalVM Native Image トラブルシューティング機能の最新状況(2025年版)
ntt_dsol_java
0
170
Featured
See All Featured
Writing Fast Ruby
sferik
630
62k
Rails Girls Zürich Keynote
gr2m
95
14k
Building Applications with DynamoDB
mza
96
6.8k
Automating Front-end Workflow
addyosmani
1371
200k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Designing for humans not robots
tammielis
254
26k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Why Our Code Smells
bkeepers
PRO
340
57k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.3k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
The Language of Interfaces
destraynor
162
25k
Side Projects
sachag
455
43k
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