Class: Skylight::CLI Private

Inherits:
Thor show all
Defined in:
lib/skylight/cli.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary

Constants inherited from Thor

Thor::DynamicTask, Thor::HELP_MAPPINGS, Thor::HiddenTask, Thor::THOR_RESERVED_WORDS, Thor::Task, Thor::UndefinedTaskError, Thor::VERSION

Instance Attribute Summary

Attributes included from Thor::Base

#args, #options, #parent_options

Instance Method Summary collapse

Methods inherited from Thor

check_unknown_options!, check_unknown_options?, command_help, default_command, desc, #help, help, long_desc, map, method_option, method_options, package_name, printable_commands, register, stop_on_unknown_option!, stop_on_unknown_option?, subcommand, subcommands

Methods included from Thor::Base

included, #initialize, register_klass_file, shell, shell=, subclass_files, subclasses

Instance Method Details

#setup(token = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/skylight/cli.rb', line 14

def setup(token=nil)
  if File.exist?(config_path)
    say "Your app is already on Skylight. http://www.skylight.io", :green
    return
  end

  unless token
    api.authentication = 
  end

  res = api.create_app(app_name, token)

  config[:application]    = res.get('app.id')
  config[:authentication] = res.get('app.token')
  config.write(config_path)

  say "Congratulations. Your application is on Skylight! http://www.skylight.io", :green
  say <<-OUT

The application was registered for you and we generated a config file
containing your API token at:

  #{relative_config_path}

The next step is for you to deploy your application to production. The
easiest way is to just commit the config file to your source control
repository and deploy from there. You can learn more about the process at:

  http://docs.skylight.io/getting-started/#deploy

If you want to specify the authentication token as an environment variable,
you should set the `SKYLIGHT_AUTHENTICATION` variable to:

  #{config[:authentication]}

  OUT
rescue Api::CreateFailed => e
  say "Could not create the application", :red
  say e.to_s, :yellow
rescue Interrupt
end