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
580
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
33
Khmer ASR using Deep Learning
lchanmann
0
310
Path Finding using Search Algorithms
lchanmann
0
31
The secret to a good life
lchanmann
0
39
Monit - unix monitoring utility
lchanmann
1
100
Techcamp PP
lchanmann
0
100
Trying out Verboice
lchanmann
1
83
CoffeeScript
lchanmann
4
190
Other Decks in Programming
See All in Programming
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
3
700
Quine, Polyglot, 良いコード
qnighy
4
650
Better Code Design in PHP
afilina
PRO
0
130
最新TCAキャッチアップ
0si43
0
200
Arm移行タイムアタック
qnighy
0
340
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
610
CSC509 Lecture 13
javiergs
PRO
0
110
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
250
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
360
初めてDefinitelyTypedにPRを出した話
syumai
0
420
[Do iOS '24] Ship your app on a Friday...and enjoy your weekend!
polpielladev
0
110
Outline View in SwiftUI
1024jp
1
340
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
The Language of Interfaces
destraynor
154
24k
Navigating Team Friction
lara
183
14k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Statistics for Hackers
jakevdp
796
220k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
110
A Tale of Four Properties
chriscoyier
156
23k
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