Blame view

script/boxen-git-credential 713 Bytes
28d13c35c   John Barnette   Add script/boxen-...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  #!/usr/bin/ruby
  # Provide git credentials using Boxen's config.
  
  unless command = ARGV.shift
    this = File.basename $0
    abort "Usage: #{this} <get|store|erase>"
  end
  
  # We only support get.
  
  exit 0 unless command == "get"
  
  # Make sure we're looking for github.com stuff.
  
  attrs = Hash[$stdin.read.split($/).map { |l| l.split("=") }]
  exit 1 unless attrs["host"] == "github.com"
  
  require "pathname"
  
  # Put us where we belong, in the root dir of our boxen repo.
  
  Dir.chdir Pathname.new(__FILE__).realpath + "../.."
  
  # Set up our local configuration, deps, and load path.
  
  load "config/basic.rb"
  
  require "boxen/config"
  
  config = Boxen::Config.load
  
  puts "username=#{config.login}"
  puts "password=#{config.password}"