Class: ThemeJuice::CLI
- Inherits:
-
Thor
- Object
- Thor
- ThemeJuice::CLI
show all
- Defined in:
- lib/theme-juice/cli.rb
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
For dynamic methods defined within the config
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
# File 'lib/theme-juice/cli.rb', line 215
def method_missing(method, *args, &block)
parser = Thor::Options.new self.class.class_options
@options = parser.parse args
init_env
err = -> { @io.error "Could not find command '#{method}'" }
err.call unless @config.exist?
if @config.commands.has_key? "#{method}"
@config.command method.to_sym, args
else
err.call
end
end
|
Instance Method Details
#create ⇒ Object
155
156
157
158
|
# File 'lib/theme-juice/cli.rb', line 155
def create
@io.hello
@create.new(options).execute
end
|
#delete ⇒ Object
186
187
188
|
# File 'lib/theme-juice/cli.rb', line 186
def delete
@delete.new(options).unexecute
end
|
#deploy(stage, *args) ⇒ Object
193
194
195
|
# File 'lib/theme-juice/cli.rb', line 193
def deploy(stage, *args)
@deploy.new(options).send(stage, *args).execute
end
|
#env ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/theme-juice/cli.rb', line 113
def env
if options[:property].nil?
@io.list "Environment:", :green, @env.inspect
else
prop = options[:property].gsub "-", "_"
@io.error "Environment property '#{prop}' does not exist",
NotImplementedError unless @env.respond_to? prop
@io.say @env.send(prop), :color => :green
end
end
|
#help(command = nil) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/theme-juice/cli.rb', line 86
def help(command = nil)
root = File.expand_path "../man", __FILE__
man = ["tj", command].compact.join("-")
begin
man_path = "#{root}/#{man}"
if File.exist? man_path
shell_escaped_man_path = man_path.shellescape
if OS.windows?
@io.say File.read("#{shell_escaped_man_path}.txt"), :color => :white
else
@util.run "man #{shell_escaped_man_path}", :verbose => @env.verbose
end
else
@io.say "No man page available for '#{command}'", :color => :red
end
rescue
super
end
end
|
#init ⇒ Object
128
129
130
131
132
133
134
|
# File 'lib/theme-juice/cli.rb', line 128
def init
@io.say "Initializing the VM...", {
:color => [:black, :on_green, :bold],
:row => true
}
@init.new(options).execute
end
|
#list ⇒ Object
198
199
200
|
# File 'lib/theme-juice/cli.rb', line 198
def list
@list.new(options).list :projects
end
|
#setup ⇒ Object
176
177
178
179
|
# File 'lib/theme-juice/cli.rb', line 176
def setup
@io.hello
@create.new(options.dup.merge(:bare => true)).execute
end
|
#update(*args) ⇒ Object
203
204
205
|
# File 'lib/theme-juice/cli.rb', line 203
def update(*args)
@update.new(options).execute
end
|
#version ⇒ Object
107
108
109
|
# File 'lib/theme-juice/cli.rb', line 107
def version
@io.say @version, :color => :green
end
|
#vm(*args) ⇒ Object
208
209
210
211
212
|
# File 'lib/theme-juice/cli.rb', line 208
def vm(*args)
@util.inside @env.vm_path do
@util.run "vagrant #{args.join(" ")}", :verbose => @env.verbose
end
end
|