class Dronr::CLI

Constants

IS_RAILS_APP

TODO you need a better way to detect if dronr is being run within a Rails app. Maybe don’t detect, just load Thor::Rails for the specific methods that require it? esp. since it’s currently impossible to run full path commands e.g. ‘~/Code/appname/bin/dronr up`

Public Instance Methods

new(app_name) click to toggle source
# File lib/dronr/cli.rb, line 19
def new(app_name)
  app_requirement(false)

  # TODO allow CLI params thru
  #   # args = Rails::Generators::ARGVScrubber.new([]).prepare!
  #   args = [app_name]

  template_register = if template_path = options[:template]
    Register.load(template_path)
  else
    Register.new
  end

  Dronr::Manager.from_scratch(app_name, template_register)
end
up() click to toggle source
# File lib/dronr/cli.rb, line 49
def up
  app_requirement(true)

  Dronr::Manager.existing({ loop: options[:loop] })

end

Protected Instance Methods

app_requirement(required) click to toggle source
# self destruct, yank self completely

end

# File lib/dronr/cli.rb, line 67
def app_requirement(required)
  if IS_RAILS_APP
    raise "FATAL: Existing app detected: #{::Rails.application}" if !required
  else
    raise "FATAL: App not found" if required
  end
end