Module: Spire::Commands::Mixins::Authenticate

Included in:
Console
Defined in:
lib/spire/commands/mixins/authenticate.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(target) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/spire/commands/mixins/authenticate.rb', line 8

def self.included(target)
  target.module_eval do
    
    include Mixlib::CLI
    
    option :email, 
      :short => "-e EMAIL",
      :long  => "--email EMAIL",
      :description => "The email for your account"

    option :password, 
      :short => "-p PASSWORD",
      :long  => "--password PASSWORD",
      :description => "The password for your account"

    option :secret,
      :short => "-s SECRET",
      :long => "--secret SECRET",
      :description => "The account secret for your account"
  end
  
end

Instance Method Details

#connectObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/spire/commands/mixins/authenticate.rb', line 31

def connect
  if config[:email]
    if !config[:password]
      config[:password] = ask("Password:") { |q| q.echo = false}
    end
    spire = Spire.new(CLI.url)
    spire.(config[:email],config[:password])
    return spire
  else 
    if !config[:secret]
      if CLI.rc["secret"]
        config[:secret] = CLI.rc["secret"]
      else
        raise "No secret provided or found in ~/.spirerc"
      end
    end
    spire = Spire.new(CLI.url)
    spire.start(config[:secret])
    return spire
  end
end