Class: Locomotive::Wagon::CLI::Main
- Includes:
- CheckPath, ForceColor
- Defined in:
- lib/locomotive/wagon/cli.rb
Instance Method Summary collapse
- #auth(email = nil, password = nil, platform_url = nil) ⇒ Object
- #backup(name, host, path = '.') ⇒ Object
- #delete(env, resource, slug = nil, path = '.') ⇒ Object
- #deploy(env, path = '.') ⇒ Object
- #init(name, path = '.', *generator_options) ⇒ Object
- #list_templates ⇒ Object
- #pull(env, path = '.') ⇒ Object
- #serve(path = '.') ⇒ Object
- #stop(path = '.') ⇒ Object
- #sync(env, path = '.') ⇒ Object
- #version ⇒ Object
Methods included from ForceColor
Instance Method Details
#auth(email = nil, password = nil, platform_url = nil) ⇒ Object
226 227 228 229 230 231 232 233 234 235 |
# File 'lib/locomotive/wagon/cli.rb', line 226 def auth(email = nil, password = nil, platform_url = nil) say "Locomotive Sign in/up\n\n", :bold platform_url ||= ask("Enter the URL of your platform? (default: #{Locomotive::Wagon::DEFAULT_PLATFORM_URL})") platform_url = Locomotive::Wagon::DEFAULT_PLATFORM_URL if platform_url.strip == '' while email.to_s.strip == ''; email = ask('Enter your e-mail?'); end while password.to_s.strip == ''; password = ask('Enter your password?', echo: false); end Locomotive::Wagon.authenticate(platform_url, email, password, shell) end |
#backup(name, host, path = '.') ⇒ Object
266 267 268 269 270 271 272 273 274 275 |
# File 'lib/locomotive/wagon/cli.rb', line 266 def backup(name, host, path = '.') begin if Locomotive::Wagon.clone(name, path, { host: host }.merge(), shell) self.print_next_instructions_when_site_created(name, path, false) end rescue Exception => e self.print_exception(e, [:verbose]) exit(1) end end |
#delete(env, resource, slug = nil, path = '.') ⇒ Object
399 400 401 402 403 404 405 406 |
# File 'lib/locomotive/wagon/cli.rb', line 399 def delete(env, resource, slug = nil, path = '.') if ask('Are you sure?', limited_to: %w(yes no)) == 'yes' Locomotive::Wagon.delete(env, path, resource, slug, shell) else say 'The delete operation has been cancelled', :red exit(1) end end |
#deploy(env, path = '.') ⇒ Object
347 348 349 350 351 352 353 354 355 356 357 358 |
# File 'lib/locomotive/wagon/cli.rb', line 347 def deploy(env, path = '.') force_color_if_asked() if check_path!(path) begin Locomotive::Wagon.push(env, path, , [:shell] ? shell : nil) rescue Exception => e self.print_exception(e, [:verbose]) exit(1) end end end |
#init(name, path = '.', *generator_options) ⇒ Object
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/locomotive/wagon/cli.rb', line 240 def init(name, path = '.', *) force_color_if_asked() require 'locomotive/wagon/generators/site' require File.([:lib]) if [:lib] generator = Locomotive::Wagon::Generators::Site.get(:blank) if generator.nil? say "Unknown site template '#{[:template]}'", :red exit(1) else begin if Locomotive::Wagon.init(generator.klass, [name, path, *], { force_color: [:force_color] }) self.print_next_instructions_when_site_created(name, path) end rescue GeneratorException => e self.print_exception(e, [:verbose]) exit(1) end end end |
#list_templates ⇒ Object
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/locomotive/wagon/cli.rb', line 290 def list_templates force_color_if_asked() require 'locomotive/wagon/generators/site' require File.([:lib]) if [:lib] if Locomotive::Wagon::Generators::Site.empty? say 'No templates', :red elsif ![:json] Locomotive::Wagon::Generators::Site.list.each do |info| say info.name, :bold, false say " - #{info.description}" unless info.description.blank? end else say Locomotive::Wagon::Generators::Site.list_to_json end end |
#pull(env, path = '.') ⇒ Object
377 378 379 380 381 382 383 384 385 386 |
# File 'lib/locomotive/wagon/cli.rb', line 377 def pull(env, path = '.') if check_path!(path) begin Locomotive::Wagon.pull(env, path, , shell) rescue Exception => e self.print_exception(e, [:verbose]) exit(1) end end end |
#serve(path = '.') ⇒ Object
315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/locomotive/wagon/cli.rb', line 315 def serve(path = '.') force_color_if_asked() if check_path!(path) begin Locomotive::Wagon.serve(path, , shell) rescue Exception => e self.print_exception(e, [:verbose]) exit(1) end end end |
#stop(path = '.') ⇒ Object
328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/locomotive/wagon/cli.rb', line 328 def stop(path = '.') force_color_if_asked() if check_path!(path) begin Locomotive::Wagon.stop(path, false, shell) rescue Exception => e say e., :red exit(1) end end end |
#sync(env, path = '.') ⇒ Object
363 364 365 366 367 368 369 370 371 372 |
# File 'lib/locomotive/wagon/cli.rb', line 363 def sync(env, path = '.') if check_path!(path) begin Locomotive::Wagon.sync(env, path, , shell) rescue Exception => e self.print_exception(e, [:verbose]) exit(1) end end end |
#version ⇒ Object
220 221 222 223 |
# File 'lib/locomotive/wagon/cli.rb', line 220 def version require 'locomotive/wagon/version' say Locomotive::Wagon::VERSION end |