Class: Zencoder::CLI::Command::Setup

Inherits:
Base
  • Object
show all
Defined in:
lib/zencoder-cli/commands/setup.rb

Class Method Summary collapse

Methods inherited from Base

extract_id, provides

Methods included from Helpers

#ask, #confirm, #display, #error, #format_date, #home_directory, #running_on_a_mac?, #running_on_windows?, #truncate

Class Method Details

.delete(args, global_options, command_options) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/zencoder-cli/commands/setup.rb', line 34

def delete(args, global_options, command_options)
  if confirm
    delete_setup
    display "#{home_directory}/.zencoder has been removed."
  else
    display "Ok, nothing changed."
  end
end

.run(args, global_options, command_options) ⇒ Object



13
14
15
16
17
# File 'lib/zencoder-cli/commands/setup.rb', line 13

def run(args, global_options, command_options)
  display("Enter Your Zencoder API Key: ", false)
  save_api_key(global_options[:environment], ask)
  display "Your API key has been saved to #{home_directory}/.zencoder/api-key."
end

.show(args, global_options, command_options) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/zencoder-cli/commands/setup.rb', line 19

def show(args, global_options, command_options)
  if File.exist?("#{home_directory}/.zencoder/api-key")
    keys = YAML.load_file("#{home_directory}/.zencoder/api-key")
    if keys.length == 1
      display("Your API Key: ", false)
      puts keys.values.first
    else
      display("Your API Keys: ")
      puts table(nil, *keys.to_a)
    end
  else
    display("You have no API keys stored. Run `zencoder setup` to get started.")
  end
end