lib/gondler/cli.rb in gondler-0.1.1 vs lib/gondler/cli.rb in gondler-0.1.2

- old
+ new

@@ -1,7 +1,6 @@ require 'thor' -require 'readline' require 'pathname' require 'gondler' module Gondler class CLI < Thor @@ -13,31 +12,38 @@ set_environments end desc 'install', 'Install the dependecies specified in your Gomfile' - method_option :without, :type => :array, :default => [] + method_option :without, :type => :array, :default => nil def install - gomfile.packages.each do |package| - puts "Install #{package}" - package.resolve + Gondler.without(options[:without] || []) do + gomfile.packages.each do |package| + puts "Install #{package}" + package.resolve + end end rescue Gondler::Package::InstallError => e puts e.message exit(1) end desc 'build', 'Build with dependencies specified in your Gomfile' def build(*args) - invoke :exec, %w(go build) + args + invoke :go, %w(build) + args end desc 'test', 'Test with dependencies specified in your Gomfile' def test(*args) - invoke :exec, %w(go test) + args + invoke :go, %w(test) + args end + desc 'go', 'Execute go command in the context of Gondler' + def go(*args) + invoke :exec, %w(go) + args + end + desc 'exec', 'Execute a command in the context of Gondler' def exec(*args) args.map! do |arg| if arg.to_s.include?(' ') %Q{"#{arg.gsub(/"/, '\"')}"} @@ -47,37 +53,33 @@ end Kernel.exec(*args.join(' ')) end desc 'list', 'Show all of the dependencies in the current bundle' - method_option :without, :type => :array, :default => [] + method_option :without, :type => :array, :default => nil def list - Gondler.withouts = options[:without] - - puts 'Packages included by the gondler:' - gomfile.packages.each do |package| - puts " * #{package}" + Gondler.without(options[:without] || []) do + puts 'Packages included by the gondler:' + gomfile.packages.each do |package| + puts " * #{package}" + end end end desc 'repl', 'REPL in the context of Gondler' def repl - buf = Readline.readline('> ', true) - while buf - Kernel.system(buf) - - buf = Readline.readline('> ', true) - end + require 'gondler/repl' + Gondler::REPL.run end desc 'version', 'Print Gondler version' def version puts Gondler::VERSION end desc 'env', 'Print Gondler environments' - def env - system('go env') + def env(*args) + invoke :go, %w(env) + args end private def method_missing(*args)