Class: Gondler::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/gondler/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CLI

Returns a new instance of CLI.



10
11
12
13
14
# File 'lib/gondler/cli.rb', line 10

def initialize(*args)
  super

  set_environments
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object (private)



88
89
90
91
92
93
94
95
96
97
98
# 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

Instance Method Details

#build(*args) ⇒ Object



33
34
35
# File 'lib/gondler/cli.rb', line 33

def build(*args)
  invoke :go, %w(build) + args
end

#env(*args) ⇒ Object



82
83
84
# File 'lib/gondler/cli.rb', line 82

def env(*args)
  invoke :go, %w(env) + args
end

#exec(*args) ⇒ Object



48
49
50
51
52
53
54
55
56
57
# 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) ⇒ Object



43
44
45
# File 'lib/gondler/cli.rb', line 43

def go(*args)
  invoke :exec, %w(go) + args
end

#installObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# 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

#listObject



61
62
63
64
65
66
67
68
# 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

#replObject



71
72
73
74
# File 'lib/gondler/cli.rb', line 71

def repl
  require 'gondler/repl'
  Gondler::REPL.run
end

#test(*args) ⇒ Object



38
39
40
# File 'lib/gondler/cli.rb', line 38

def test(*args)
  invoke :go, %w(test) + args
end

#versionObject



77
78
79
# File 'lib/gondler/cli.rb', line 77

def version
  puts Gondler::VERSION
end