Sha256: 683e71c8436049a551b7b37fa5d62786acbfc51549faa0a58fda82709b01f59d

Contents?: true

Size: 1.09 KB

Versions: 9

Compression:

Stored size: 1.09 KB

Contents

module StackFu::Commands
  class ConfigCommand < Command
    include StackFu::ApiHooks
    include StackFu::ProvidersCredentials
    
    def default(parameters, options)
      while true
        login = options[:login] || ask("StackFu Login: ")
        token = options[:token] || ask("StackFu Token: ")
      
        break if options[:login] and options[:token]
        
        puts ""
        break if agree("Is this information correct? ", true)
        puts ""
        puts "OK, let's try it again"
        puts ""
      end
    
      puts ""
      puts "Configuration saved to #{ENV['HOME']}/.stackfu"
      save_config(login, token)
    end
    
    def webbynode(parameters, options)
      user = spinner { User.find(:all).first }
      add_webbynode_credentials(user)
    end
  
    def slicehost(parameters, options)
      user = spinner { User.find(:all).first }
      add_slicehost_credentials(user)
    end
  
    private
  
    def save_config(login, token)
      File.open("#{ENV["HOME"]}/.stackfu", "w") do |file|
        YAML.dump({ :login => login, :token => token }, file)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
stackfu-0.1.8.1 lib/stackfu/commands/config_command.rb
stackfu-0.1.8 lib/stackfu/commands/config_command.rb
stackfu-0.1.7 lib/stackfu/commands/config_command.rb
stackfu-0.1.6 lib/stackfu/commands/config_command.rb
stackfu-0.1.5 lib/stackfu/commands/config_command.rb
stackfu-0.1.4 lib/stackfu/commands/config_command.rb
stackfu-0.1.3 lib/stackfu/commands/config_command.rb
stackfu-0.1.2.2 lib/stackfu/commands/config_command.rb
stackfu-0.1.2.1 lib/stackfu/commands/config_command.rb