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
630
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
50
Khmer ASR using Deep Learning
lchanmann
0
470
Path Finding using Search Algorithms
lchanmann
0
61
The secret to a good life
lchanmann
0
64
Monit - unix monitoring utility
lchanmann
1
120
Techcamp PP
lchanmann
0
120
Trying out Verboice
lchanmann
1
110
CoffeeScript
lchanmann
4
210
Other Decks in Programming
See All in Programming
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
4
3.6k
複数ドメインを一つのアプリに統合するFlutterの設計と運用_FlutterKaigi2026登壇資料(須永高弘)
takahirosunaga
0
140
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
560
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
2
260
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
120
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
340
React Native経験者が Flutterを30⽇間触って驚いたこと
3saito
0
140
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
3
1.4k
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
320
[JA] Domain Modeling with Vanilla Rails: 「操作」から再考するRailsの設計論
yasaichi
4
1.8k
Kotlinize Is Not Just Converting to Kotlin
chigichan24
1
220
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
870
Featured
See All Featured
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
240
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.4k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1.1k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
60k
How to train your dragon (web standard)
notwaldorf
96
6.9k
Prompt Engineering for Job Search
mfonobong
0
570
Crafting Experiences
bethany
1
420
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Building an army of robots
kneath
307
47k
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
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