class Gondler::CLI
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/gondler/cli.rb, line 10 def initialize(*args) super set_environments end
Public Instance Methods
build(*args)
click to toggle source
# File lib/gondler/cli.rb, line 33 def build(*args) invoke :go, %w(build) + args end
env(*args)
click to toggle source
# File lib/gondler/cli.rb, line 82 def env(*args) invoke :go, %w(env) + args end
exec(*args)
click to toggle source
# File lib/gondler/cli.rb, line 48 def exec(*args) args.map! do |arg| if arg.to_s.include?(' ') %Q{"#{arg.gsub(/"/, '\"')}"} else arg end end Kernel.exec(*args.join(' ')) end
go(*args)
click to toggle source
# File lib/gondler/cli.rb, line 43 def go(*args) invoke :exec, %w(go) + args end
install()
click to toggle source
# File lib/gondler/cli.rb, line 18 def install Gondler.without(options[:without] || []) do gomfile.packages.each do |package| puts "Install #{package}" package.resolve end end gomfile.itself_package.get if gomfile.itself_package rescue Gondler::Package::InstallError => e puts e.message exit(1) end
list()
click to toggle source
# File lib/gondler/cli.rb, line 61 def list Gondler.without(options[:without] || []) do puts 'Packages included by the gondler:' gomfile.packages.each do |package| puts " * #{package}" end end end
repl()
click to toggle source
# File lib/gondler/cli.rb, line 71 def repl require 'gondler/repl' Gondler::REPL.run end
test(*args)
click to toggle source
# File lib/gondler/cli.rb, line 38 def test(*args) invoke :go, %w(test) + args end
version()
click to toggle source
# File lib/gondler/cli.rb, line 77 def version puts Gondler::VERSION end
Private Instance Methods
executable?(name)
click to toggle source
# File lib/gondler/cli.rb, line 107 def executable?(name) system("hash #{name} 1> /dev/null 2>&1") end
gomfile()
click to toggle source
# File lib/gondler/cli.rb, line 111 def gomfile @gomfile ||= Gondler::Gomfile.new(options[:gomfile]) rescue Gomfile::NotFound => e say(e.message, :red) exit(1) end
method_missing(*args)
click to toggle source
# File lib/gondler/cli.rb, line 88 def method_missing(*args) if executable?(args.first) invoke(:exec, args) elsif executable?("gondler-#{args.first}") args[0] = "gondler-#{args.first}" invoke(:exec, args) else STDERR.puts(%Q{Could not find command "#{args.first}"}) exit(1) end end
set_environments()
click to toggle source
# File lib/gondler/cli.rb, line 100 def set_environments path = Pathname.new(options[:path]) path = Pathname.pwd + path unless path.absolute? Gondler.env.path = path ENV['PATH'] = "#{path + 'bin'}:#{ENV['PATH']}" end