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
590
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
37
Khmer ASR using Deep Learning
lchanmann
0
420
Path Finding using Search Algorithms
lchanmann
0
46
The secret to a good life
lchanmann
0
44
Monit - unix monitoring utility
lchanmann
1
110
Techcamp PP
lchanmann
0
110
Trying out Verboice
lchanmann
1
95
CoffeeScript
lchanmann
4
200
Other Decks in Programming
See All in Programming
tparseでgo testの出力を見やすくする
utgwkk
2
310
Go コードベースの構成と AI コンテキスト定義
andpad
0
150
[AtCoder Conference 2025] LLMを使った業務AHCの上⼿な解き⽅
terryu16
6
920
AI前提で考えるiOSアプリのモダナイズ設計
yuukiw00w
0
200
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
430
AI Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
5
1.4k
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
140
ThorVG Viewer In VS Code
nors
0
300
ZJIT: The Ruby 4 JIT Compiler / Ruby Release 30th Anniversary Party
k0kubun
1
300
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
1.8k
開発に寄りそう自動テストの実現
goyoki
2
1.5k
AIの誤りが許されない業務システムにおいて“信頼されるAI” を目指す / building-trusted-ai-systems
yuya4
6
4k
Featured
See All Featured
More Than Pixels: Becoming A User Experience Designer
marktimemedia
2
260
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
350
Making Projects Easy
brettharned
120
6.5k
New Earth Scene 8
popppiees
0
1.3k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
40
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.2k
First, design no harm
axbom
PRO
1
1.1k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
0
68
Being A Developer After 40
akosma
91
590k
Raft: Consensus for Rubyists
vanstee
141
7.3k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
190
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
29
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