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
570
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
31
Khmer ASR using Deep Learning
lchanmann
0
260
Path Finding using Search Algorithms
lchanmann
0
23
The secret to a good life
lchanmann
0
33
Monit - unix monitoring utility
lchanmann
1
93
Techcamp PP
lchanmann
0
95
Trying out Verboice
lchanmann
1
79
CoffeeScript
lchanmann
4
190
Other Decks in Programming
See All in Programming
if constexpr文はテンプレート世界のラムダ式である
faithandbrave
3
650
Ruby GitHub Packages
bkuhlmann
0
630
GitHub Copilotのススメ
marcy731
1
200
『Railsオワコン』と言われる時代に、なぜブルーモ証券はRailsを選ぶのか
free_world21
0
250
TYPO3 v13 – The road to LTS: What's new and new APIs
luisasofie_xoxo
0
210
VSCodeでのDatabricks開発もお勧めしたい/I would also recommend Databricks development with VSCode.
kazumain
0
260
Micro Frontends for Java Microservices - Devnexus 2024
mraible
PRO
0
490
ゆるい個人開発のススメ
kuroppe1819
10
990
Zero Waste, Radical Magic, and Italian Graft – Quarkus Efficiency Secrets
hollycummins
0
230
Azure OpenAI Serviceのプロンプトエンジニアリング入門
tomokusaba
3
710
DMMプラットフォームがTiDB Cloudを採用した背景
pospome
8
4.1k
Compose-View Interop in Practice (mDevCamp 2024)
stewemetal
0
140
Featured
See All Featured
Docker and Python
trallard
34
2.7k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
322
20k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
34
8.9k
Fashionably flexible responsive web design (full day workshop)
malarkey
398
65k
Rebuilding a faster, lazier Slack
samanthasiow
73
8.2k
Principles of Awesome APIs and How to Build Them.
keavy
121
16k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
14
1.6k
WebSockets: Embracing the real-time Web
robhawkes
59
7k
The Brand Is Dead. Long Live the Brand.
mthomps
49
29k
Creatively Recalculating Your Daily Design Routine
revolveconf
210
11k
Practical Orchestrator
shlominoach
182
9.7k
Learning to Love Humans: Emotional Interface Design
aarron
267
39k
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