Module: Vaultez::Commands::Fetch

Included in:
Vaultez::CLI
Defined in:
lib/vaultez/commands/fetch.rb

Instance Method Summary collapse

Instance Method Details

#fetchObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/vaultez/commands/fetch.rb', line 4

def fetch
  client = Vaultez::Client.new

  if options[:companies]
    fetch_companies(client)
  elsif options[:projects]
    fetch_projects(client)
  elsif options[:project] && options[:secret]
    fetch_secret(client)
  elsif options[:project]
    fetch_secrets(client)
  else
    puts "Error: not enough options. See `vaultez help fetch`."
    exit 1
  end
rescue Vaultez::NotAuthenticatedError => error
  puts "Error: #{error.message}"
  exit 1
rescue Vaultez::NotFoundError => error
  puts "Error: #{error.message}"
  exit 1
rescue Vaultez::ApiError => error
  puts "Error: #{error.message}"
  exit 1
end