Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Thor - Building CLI with ruby
Search
Mann
September 08, 2012
Programming
640
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
Transcript
16 slides
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
More Decks by Mann
See All by Mann
From Cambodia to Mizzou
lchanmann
0
50
Khmer ASR using Deep Learning
lchanmann
0
470
Path Finding using Search Algorithms
lchanmann
0
62
The secret to a good life
lchanmann
0
68
Monit - unix monitoring utility
lchanmann
1
130
Techcamp PP
lchanmann
0
120
Trying out Verboice
lchanmann
1
110
CoffeeScript
lchanmann
4
210
Other Decks in Programming
See All in Programming
AIが生成したコードは読むべきか?抽象化設計とコードの品質保証 / abstraction-design-and-quality
minodriven
16
9.4k
AI Augmentation Techniques with Liberty
ivargrimstad
1
520
SFCで実現する病院・医療システムの動的組み立て式UI
koukimiura
1
180
Claude Codeのおかげでやりたいことがやれるようになったんだよォー!
sms_tech
0
160
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
210
テストだけで見つかる? Rubyでつくるメソッド発掘器
izawa
0
140
Crash Auto Pipelines
veronikapj
1
440
自宅サーバはどこまで再現できるのか - Proxmox VE上のVM環境をIaCとバックアップで戻してみた
youto
0
430
Vapor Mode でアクセシビリティは 壊れないか検証した話
fuqda
1
350
複数ドメインを一つのアプリに統合するFlutterの設計と運用_FlutterKaigi2026登壇資料(須永高弘)
takahirosunaga
0
200
imagewebp()の向こう側: WebPはなぜ JPEG・PNGより軽いのか
yuzneri
0
130
Debian JP Projectのサーバー構成
uwabami
1
140
Featured
See All Featured
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
290
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.3k
Navigating Weather and Climate Data
rabernat
0
590
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Speed Design
sergeychernyshev
33
2.2k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
Designing Experiences People Love
moore
143
24k
Design in an AI World
tapps
1
390
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
570
First, design no harm
axbom
PRO
2
1.4k
Music & Morning Musume
bryan
48
7.5k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k