SlideShare a Scribd company logo
1 of 11
Commander
S i m o n C O U R T O I S
   ( @ h a p p y n o f f )
Commander ?

Solution complète pour créer des outils en
ligne de commande

github.com/visionmedia/commander

gem install commander
Exemple Basique
# prog
#!/usr/bin/env

require 'rubygems'
require 'commander/import'

program :name, 'Prog'
program :version, '1.0.0'
program :description, 'Exemple pour Paris.rb'

command :parisrb do |c|
  c.syntax = 'foobar parisrb'
  c.description = 'Dis bonjour'
  c.action do |args, options|
    say 'Bonjour Paris.rb'
  end
end
Exemple Basique

$ prog parisrb
Bonjour Paris.rb



$ prog help parisrb
NAME:
  parisrb

DESCRIPTION:
  Dis bonjour

SYNOPSIS:
  prog parisrb
Avec Options

command :parisrb do |c|
  c.syntax = 'foobar parisrb'
  c.description = 'Dis bonjour’

  c.option '--prefix STRING', String, 'Ajouter un prefix'
  c.option '--suffix STRING', String, 'Ajouter un suffix'

  c.action do |args, opts|
    opts.default :prefix => '(', :suffix => ')'
    say “#{opts[:prefix]}Bonjour Paris.rb #{opts[:suffix]}”
  end
end
Avec Options
$ prog parisrb
(Bonjour Paris.rb)



$ prog parisrb --prefix ‘!’ --suffix ‘!’
!Bonjour Paris.rb!



$ prog help parisrb
...
OPTIONS:
    --prefix STRING
         Ajouter prefix
    --suffix STRING
         Ajouter suffix
Plusieurs
            Commandes

command :parisrb do |c|
  # ...
end

command :plop do |c|
  # ...
end

command :hello do |c|
  # ...
end
Highline +
       Améliorations
ask “Your name:”
# Your name:
# (prompt)

ask “Your name: ”
# Your name: (prompt)

password “Your password: ”
# Your password: ********

agree("Do something ? ")
# Do something ? (prompt: yes/no)

choice = choose("Favorite language?", :ruby, :perl, :js)
# Favorite language?
# 1. ruby
# 2. perl
# 3. js
? (prompt: 1/2/3)
Highline +
       Améliorations
speak “Hello Paris.rb”
# -- synthèse vocale --

names = ask_for_array 'Names: '   # Array
bday = ask_for_date 'Birthday ? ' # Date

times = [1, 2, 3]
progress times do |time|
  sleep(time)
end
# Progress |.........................| 0% complete
# Progress |========.................| 33% complete
# Progress |================.........| 66% complete
# Process complete
What else ?

Customisation facile

Aliasing de commandes

Commande par défaut

Interaction avec growl (notify, notify_ok)

github.com/visionmedia/terminal-table
MERCI !

More Related Content

What's hot

Applied Shell Scripting - stills to time-lapse
Applied Shell Scripting - stills to time-lapseApplied Shell Scripting - stills to time-lapse
Applied Shell Scripting - stills to time-lapseShoaib Sufi
 
PyGame Tutorial | PyGame Python Tutorial For Beginners | Python Certification...
PyGame Tutorial | PyGame Python Tutorial For Beginners | Python Certification...PyGame Tutorial | PyGame Python Tutorial For Beginners | Python Certification...
PyGame Tutorial | PyGame Python Tutorial For Beginners | Python Certification...Edureka!
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)Lin Yo-An
 
Value protocols and codables
Value protocols and codablesValue protocols and codables
Value protocols and codablesFlorent Vilmart
 
Parse, scale to millions
Parse, scale to millionsParse, scale to millions
Parse, scale to millionsFlorent Vilmart
 
East Bay Ruby Tropo presentation
East Bay Ruby Tropo presentationEast Bay Ruby Tropo presentation
East Bay Ruby Tropo presentationAdam Kalsey
 
Introduction to Programming in Go
Introduction to Programming in GoIntroduction to Programming in Go
Introduction to Programming in GoAmr Hassan
 
Perl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersPerl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersKirk Kimmel
 

What's hot (12)

Applied Shell Scripting - stills to time-lapse
Applied Shell Scripting - stills to time-lapseApplied Shell Scripting - stills to time-lapse
Applied Shell Scripting - stills to time-lapse
 
Sol7
Sol7Sol7
Sol7
 
PyGame Tutorial | PyGame Python Tutorial For Beginners | Python Certification...
PyGame Tutorial | PyGame Python Tutorial For Beginners | Python Certification...PyGame Tutorial | PyGame Python Tutorial For Beginners | Python Certification...
PyGame Tutorial | PyGame Python Tutorial For Beginners | Python Certification...
 
nginx mod PSGI
nginx mod PSGInginx mod PSGI
nginx mod PSGI
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)
 
Value protocols and codables
Value protocols and codablesValue protocols and codables
Value protocols and codables
 
Ansible on AWS
Ansible on AWSAnsible on AWS
Ansible on AWS
 
Parse, scale to millions
Parse, scale to millionsParse, scale to millions
Parse, scale to millions
 
East Bay Ruby Tropo presentation
East Bay Ruby Tropo presentationEast Bay Ruby Tropo presentation
East Bay Ruby Tropo presentation
 
Dig1108 Lesson 3
Dig1108 Lesson 3Dig1108 Lesson 3
Dig1108 Lesson 3
 
Introduction to Programming in Go
Introduction to Programming in GoIntroduction to Programming in Go
Introduction to Programming in Go
 
Perl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersPerl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one liners
 

Viewers also liked

Fake your files - MemFs
Fake your files - MemFsFake your files - MemFs
Fake your files - MemFsSimon Courtois
 
University ces[1]
University ces[1]University ces[1]
University ces[1]da-iz
 
GPA MA Chapter March 27: Logic Models a Different Perspective
GPA MA Chapter March 27: Logic Models a Different PerspectiveGPA MA Chapter March 27: Logic Models a Different Perspective
GPA MA Chapter March 27: Logic Models a Different PerspectiveLisa Glickstein
 
Session 2 benefits of appraisals
Session 2 benefits of appraisalsSession 2 benefits of appraisals
Session 2 benefits of appraisalslisamckay
 
Anthropometric tests blood pressure session 5
Anthropometric tests blood pressure   session 5Anthropometric tests blood pressure   session 5
Anthropometric tests blood pressure session 5lisamckay
 
Anthropometric tests blood pressure session 5
Anthropometric tests blood pressure   session 5Anthropometric tests blood pressure   session 5
Anthropometric tests blood pressure session 5lisamckay
 
Vos Regexps sont fausses !
Vos Regexps sont fausses !Vos Regexps sont fausses !
Vos Regexps sont fausses !Simon Courtois
 

Viewers also liked (7)

Fake your files - MemFs
Fake your files - MemFsFake your files - MemFs
Fake your files - MemFs
 
University ces[1]
University ces[1]University ces[1]
University ces[1]
 
GPA MA Chapter March 27: Logic Models a Different Perspective
GPA MA Chapter March 27: Logic Models a Different PerspectiveGPA MA Chapter March 27: Logic Models a Different Perspective
GPA MA Chapter March 27: Logic Models a Different Perspective
 
Session 2 benefits of appraisals
Session 2 benefits of appraisalsSession 2 benefits of appraisals
Session 2 benefits of appraisals
 
Anthropometric tests blood pressure session 5
Anthropometric tests blood pressure   session 5Anthropometric tests blood pressure   session 5
Anthropometric tests blood pressure session 5
 
Anthropometric tests blood pressure session 5
Anthropometric tests blood pressure   session 5Anthropometric tests blood pressure   session 5
Anthropometric tests blood pressure session 5
 
Vos Regexps sont fausses !
Vos Regexps sont fausses !Vos Regexps sont fausses !
Vos Regexps sont fausses !
 

Similar to Commander

Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchinaguestcf9240
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaLin Yo-An
 
Perl Dancer for Python programmers
Perl Dancer for Python programmersPerl Dancer for Python programmers
Perl Dancer for Python programmersxSawyer
 
JIP Pipeline System Introduction
JIP Pipeline System IntroductionJIP Pipeline System Introduction
JIP Pipeline System Introductionthasso23
 
clap: Command line argument parser for Pharo
clap: Command line argument parser for Pharoclap: Command line argument parser for Pharo
clap: Command line argument parser for PharoESUG
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Wen-Tien Chang
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Wsloffenauer
 
The Perl API for the Mortally Terrified (beta)
The Perl API for the Mortally Terrified (beta)The Perl API for the Mortally Terrified (beta)
The Perl API for the Mortally Terrified (beta)Mike Friedman
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n2
name name2 n2name name2 n2
name name2 n2callroom
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 

Similar to Commander (20)

Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchina
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchina
 
Perl Dancer for Python programmers
Perl Dancer for Python programmersPerl Dancer for Python programmers
Perl Dancer for Python programmers
 
JIP Pipeline System Introduction
JIP Pipeline System IntroductionJIP Pipeline System Introduction
JIP Pipeline System Introduction
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
clap: Command line argument parser for Pharo
clap: Command line argument parser for Pharoclap: Command line argument parser for Pharo
clap: Command line argument parser for Pharo
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws
 
The Perl API for the Mortally Terrified (beta)
The Perl API for the Mortally Terrified (beta)The Perl API for the Mortally Terrified (beta)
The Perl API for the Mortally Terrified (beta)
 
ppt7
ppt7ppt7
ppt7
 
ppt2
ppt2ppt2
ppt2
 
name name2 n
name name2 nname name2 n
name name2 n
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
 
test ppt
test ppttest ppt
test ppt
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt21
ppt21ppt21
ppt21
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt17
ppt17ppt17
ppt17
 

More from Simon Courtois

Conseils pour un lancement Product Hunt réussi
Conseils pour un lancement Product Hunt réussiConseils pour un lancement Product Hunt réussi
Conseils pour un lancement Product Hunt réussiSimon Courtois
 
Organize your assets with Rails
Organize your assets with RailsOrganize your assets with Rails
Organize your assets with RailsSimon Courtois
 
Speed your Rails app creation with templates
Speed your Rails app creation with templatesSpeed your Rails app creation with templates
Speed your Rails app creation with templatesSimon Courtois
 
Dependency sorting in Ruby with TSort
Dependency sorting in Ruby with TSortDependency sorting in Ruby with TSort
Dependency sorting in Ruby with TSortSimon Courtois
 
How Unidecoder Transliterates UTF-8 to ASCII
How Unidecoder Transliterates UTF-8 to ASCIIHow Unidecoder Transliterates UTF-8 to ASCII
How Unidecoder Transliterates UTF-8 to ASCIISimon Courtois
 
Multi tenant/lang application with Ruby on Rails
Multi tenant/lang application with Ruby on RailsMulti tenant/lang application with Ruby on Rails
Multi tenant/lang application with Ruby on RailsSimon Courtois
 
Rails is like Burger King
Rails is like Burger KingRails is like Burger King
Rails is like Burger KingSimon Courtois
 
REST with Her (and let Her take care of the REST)
REST with Her (and let Her take care of the REST)REST with Her (and let Her take care of the REST)
REST with Her (and let Her take care of the REST)Simon Courtois
 
Pourquoi Ruby on Rails ça déchire ?
Pourquoi Ruby on Rails ça déchire ?Pourquoi Ruby on Rails ça déchire ?
Pourquoi Ruby on Rails ça déchire ?Simon Courtois
 

More from Simon Courtois (14)

Conseils pour un lancement Product Hunt réussi
Conseils pour un lancement Product Hunt réussiConseils pour un lancement Product Hunt réussi
Conseils pour un lancement Product Hunt réussi
 
Organize your assets with Rails
Organize your assets with RailsOrganize your assets with Rails
Organize your assets with Rails
 
Speed your Rails app creation with templates
Speed your Rails app creation with templatesSpeed your Rails app creation with templates
Speed your Rails app creation with templates
 
Dependency sorting in Ruby with TSort
Dependency sorting in Ruby with TSortDependency sorting in Ruby with TSort
Dependency sorting in Ruby with TSort
 
How Unidecoder Transliterates UTF-8 to ASCII
How Unidecoder Transliterates UTF-8 to ASCIIHow Unidecoder Transliterates UTF-8 to ASCII
How Unidecoder Transliterates UTF-8 to ASCII
 
Get Slim!
Get Slim!Get Slim!
Get Slim!
 
Multi tenant/lang application with Ruby on Rails
Multi tenant/lang application with Ruby on RailsMulti tenant/lang application with Ruby on Rails
Multi tenant/lang application with Ruby on Rails
 
Rails is like Burger King
Rails is like Burger KingRails is like Burger King
Rails is like Burger King
 
REST with Her (and let Her take care of the REST)
REST with Her (and let Her take care of the REST)REST with Her (and let Her take care of the REST)
REST with Her (and let Her take care of the REST)
 
Ruby and DCI
Ruby and DCIRuby and DCI
Ruby and DCI
 
Cells
CellsCells
Cells
 
Mustdown
MustdownMustdown
Mustdown
 
Ariane
ArianeAriane
Ariane
 
Pourquoi Ruby on Rails ça déchire ?
Pourquoi Ruby on Rails ça déchire ?Pourquoi Ruby on Rails ça déchire ?
Pourquoi Ruby on Rails ça déchire ?
 

Recently uploaded

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 

Recently uploaded (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Commander

  • 1. Commander S i m o n C O U R T O I S ( @ h a p p y n o f f )
  • 2. Commander ? Solution complète pour créer des outils en ligne de commande github.com/visionmedia/commander gem install commander
  • 3. Exemple Basique # prog #!/usr/bin/env require 'rubygems' require 'commander/import' program :name, 'Prog' program :version, '1.0.0' program :description, 'Exemple pour Paris.rb' command :parisrb do |c| c.syntax = 'foobar parisrb' c.description = 'Dis bonjour' c.action do |args, options| say 'Bonjour Paris.rb' end end
  • 4. Exemple Basique $ prog parisrb Bonjour Paris.rb $ prog help parisrb NAME: parisrb DESCRIPTION: Dis bonjour SYNOPSIS: prog parisrb
  • 5. Avec Options command :parisrb do |c| c.syntax = 'foobar parisrb' c.description = 'Dis bonjour’ c.option '--prefix STRING', String, 'Ajouter un prefix' c.option '--suffix STRING', String, 'Ajouter un suffix' c.action do |args, opts| opts.default :prefix => '(', :suffix => ')' say “#{opts[:prefix]}Bonjour Paris.rb #{opts[:suffix]}” end end
  • 6. Avec Options $ prog parisrb (Bonjour Paris.rb) $ prog parisrb --prefix ‘!’ --suffix ‘!’ !Bonjour Paris.rb! $ prog help parisrb ... OPTIONS: --prefix STRING Ajouter prefix --suffix STRING Ajouter suffix
  • 7. Plusieurs Commandes command :parisrb do |c| # ... end command :plop do |c| # ... end command :hello do |c| # ... end
  • 8. Highline + Améliorations ask “Your name:” # Your name: # (prompt) ask “Your name: ” # Your name: (prompt) password “Your password: ” # Your password: ******** agree("Do something ? ") # Do something ? (prompt: yes/no) choice = choose("Favorite language?", :ruby, :perl, :js) # Favorite language? # 1. ruby # 2. perl # 3. js ? (prompt: 1/2/3)
  • 9. Highline + Améliorations speak “Hello Paris.rb” # -- synthèse vocale -- names = ask_for_array 'Names: ' # Array bday = ask_for_date 'Birthday ? ' # Date times = [1, 2, 3] progress times do |time| sleep(time) end # Progress |.........................| 0% complete # Progress |========.................| 33% complete # Progress |================.........| 66% complete # Process complete
  • 10. What else ? Customisation facile Aliasing de commandes Commande par défaut Interaction avec growl (notify, notify_ok) github.com/visionmedia/terminal-table

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n