Class: EY::Pairing::CLI
- Inherits:
-
Object
- Object
- EY::Pairing::CLI
- Defined in:
- lib/ey_pairing/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #choose_pair ⇒ Object
- #choose_user(prompt = "Which user?") ⇒ Object
- #highline ⇒ Object
- #load_highline ⇒ Object
- #run(argv) ⇒ Object
Class Method Details
.run(argv) ⇒ Object
4 5 6 |
# File 'lib/ey_pairing/cli.rb', line 4 def self.run(argv) new.run(argv) end |
Instance Method Details
#choose_pair ⇒ Object
22 23 24 25 26 |
# File 'lib/ey_pairing/cli.rb', line 22 def choose_pair choose_user("Pairing?") do || .choice("np - Not Pairing") {nil} end end |
#choose_user(prompt = "Which user?") ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ey_pairing/cli.rb', line 28 def choose_user(prompt="Which user?") highline.choose do || .prompt = prompt .index = :none .select_by = :name EY::Pairing::Author.all.each do |user| .choice("#{user.init} (#{user.name})") {user} end yield if block_given? end end |
#highline ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/ey_pairing/cli.rb', line 40 def highline @highline ||= begin load_highline rescue LoadError require 'rubygems' load_highline end end |
#load_highline ⇒ Object
49 50 51 52 |
# File 'lib/ey_pairing/cli.rb', line 49 def load_highline require 'highline' HighLine.new(File.open('/dev/tty')) end |
#run(argv) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ey_pairing/cli.rb', line 8 def run(argv) puts "Welcome to ey-pairing v#{EY::Pairing::VERSION}" = [choose_user, choose_pair] names = .compact.map{|u| u.name }.join(" & ") email = .first.email `git config --remove-section user > /dev/null 2>&1` # remove project specific author `git config --global --replace-all user.name "#{names}"` `git config --global --replace-all user.email "#{email}"` puts %|~/.gitconfig author written: "#{names} <#{email}>"| end |