Sha256: 0c05ef63b5b04dab9f993de5fd9131185677c985510e8be27cca3818a68e370e

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

#!/usr/bin/env ruby
# coding: utf-8

require "vintner"
require "optparse"
require "pp"

class String
  def undent
    gsub /^.{#{slice(/^ +/).length}}/, ''
  end
end

def help
  puts <<-EOD.undent
  Usage: vintner [OPTIONS]
  
  options:
  -h, --help\tShow help
  -v, --version\tShow version

  commands:
  init\tCreate Vintner template file
  install\tInstall formula
  EOD
end

def install(brewfile)
  unless File.exists?(brewfile)
    puts "Brewfile not found"
    exit 1
  end
  parser = Vintner::Parser.new
  parser.parse(brewfile)
end

OptionParser.new do |opts|
  opts.on("-h", "--help") do
    display_help
    exit
  end
  opts.on("-v", "--version") do
    puts "Vintner #{Vintner::VERSION}"
    exit
  end
  opts.parse!(ARGV)
end

command, args = ARGV
case command
when "install"
  brewfile = args ? File.expand_path(args) : File.join(Dir.pwd, "Brewfile")
  install(brewfile)
when "init"
  File.open(File.join(Dir.pwd, "Brewfile"), "w") do |f|
    f.puts <<-EOD.undent
    # Brewfile is created by Vintner(Winemaker)
    # https://github.com/oame/vintner
    
    #brew "formula1"
    #brew "formula2", :url => "http://example.com/lib/formula2.rb"
    EOD
  end
  puts "Finish create Brewfile on current directory!"
else
  brewfile = File.join(Dir.pwd, "Brewfile")
  install(brewfile)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vintner-1.1 bin/vintner