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
620
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
44
Khmer ASR using Deep Learning
lchanmann
0
450
Path Finding using Search Algorithms
lchanmann
0
49
The secret to a good life
lchanmann
0
57
Monit - unix monitoring utility
lchanmann
1
120
Techcamp PP
lchanmann
0
110
Trying out Verboice
lchanmann
1
100
CoffeeScript
lchanmann
4
200
Other Decks in Programming
See All in Programming
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
560
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
280
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
190
Agentic UI
manfredsteyer
PRO
0
200
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
970
Performance Engineering for Everyone
elenatanasoiu
0
230
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
150
AIで効率化できた業務・日常
ochtum
0
150
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
780
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
130
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.5k
AI時代のUIはどこへ行く?その2!
yusukebe
22
7.5k
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
GitHub's CSS Performance
jonrohan
1033
470k
Ruling the World: When Life Gets Gamed
codingconduct
0
260
Designing for humans not robots
tammielis
254
26k
How to make the Groovebox
asonas
2
2.2k
WENDY [Excerpt]
tessaabrams
11
38k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.4k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
220
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