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
36
Khmer ASR using Deep Learning
lchanmann
0
400
Path Finding using Search Algorithms
lchanmann
0
43
The secret to a good life
lchanmann
0
42
Monit - unix monitoring utility
lchanmann
1
110
Techcamp PP
lchanmann
0
110
Trying out Verboice
lchanmann
1
92
CoffeeScript
lchanmann
4
200
Other Decks in Programming
See All in Programming
Claude CodeによるAI駆動開発の実践 〜そこから見えてきたこれからのプログラミング〜
iriikeita
0
340
AI駆動で0→1をやって見えた光と伸びしろ
passion0102
1
850
Range on Rails ―「多重範囲型」という新たな選択肢が、複雑ロジックを劇的にシンプルにしたワケ
rizap_tech
0
7.7k
Devoxx BE - Local Development in the AI Era
kdubois
0
140
What's new in Spring Modulith?
olivergierke
1
170
Foundation Modelsを実装日本語学習アプリを作ってみた!
hypebeans
0
130
Claude Agent SDK を使ってみよう
hyshu
0
1.4k
マンガアプリViewerの大画面対応を考える
kk__777
0
270
Server Side Kotlin Meetup vol.16: 内部動作を理解して ハイパフォーマンスなサーバサイド Kotlin アプリケーションを書こう
ternbusty
3
250
Software Architecture
hschwentner
6
2.3k
実践Claude Code:20の失敗から学ぶAIペアプログラミング
takedatakashi
18
8.8k
Goで実践するドメイン駆動開発 AIと歩み始めた新規プロダクト開発の現在地
imkaoru
4
900
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
253
22k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.2k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
116
20k
Product Roadmaps are Hard
iamctodd
PRO
55
11k
The Cost Of JavaScript in 2023
addyosmani
55
9.1k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
190
55k
Agile that works and the tools we love
rasmusluckow
331
21k
Gamification - CAS2011
davidbonilla
81
5.5k
Embracing the Ebb and Flow
colly
88
4.9k
Designing Experiences People Love
moore
142
24k
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