Class: Securenv::CLI::Application

Inherits:
Thor
  • Object
show all
Defined in:
lib/securenv/cli/application.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

This makes thor report the correct exit code in the event of a failure.

Returns:

  • (Boolean)


8
9
10
# File 'lib/securenv/cli/application.rb', line 8

def self.exit_on_failure?
  true
end

Instance Method Details

#get(var) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/securenv/cli/application.rb', line 35

def get(var)
  client = Securenv::Client.new({
    app: options[:app],
    stage: options[:stage]
  })
  parameter = client.get({
    variable: var
  })

  puts "#{parameter.var_name}: #{parameter.value}"
rescue Securenv::ParameterNotFoundError => e
  puts e.to_s
end

#listObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/securenv/cli/application.rb', line 69

def list
  client = Securenv::Client.new({
    app: options[:app],
    stage: options[:stage]
  })
  parameters = client.list
  if parameters.any?
    parameters.each do |param|
      puts "#{param.var_name}: #{param.value}"
    end
  else
    puts "No securenv variables are present for this app and stage"
  end

rescue Securenv::ParameterNotFoundError => e
  puts e.to_s
end

#set(var) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/securenv/cli/application.rb', line 15

def set(var)
  variable, value = var.split('=')
  if value.nil?
    raise Thor::Error.new "You must supply a value for #{variable}. To unset a value you can use : securenv unset #{variable}"
  end
  client = Securenv::Client.new({
    app: options[:app],
    stage: options[:stage]
  })
  parameter = client.set({
    variable: variable,
    value: value,
  })

  puts "Set value for parameter name #{parameter.name} for version #{parameter.version}"
end

#unset(var) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/securenv/cli/application.rb', line 52

def unset(var)
  client = Securenv::Client.new({
    app: options[:app],
    stage: options[:stage]
  })
  parameter = client.unset({
    variable: var
  })

  puts "#{parameter.name} was removed"
rescue Securenv::ParameterNotFoundError => e
  puts e.to_s
end