Class: Pgai::Cli::Env

Inherits:
Base
  • Object
show all
Defined in:
lib/pgai/cli/env.rb

Instance Method Summary collapse

Methods inherited from Base

exit_on_failure?, #initialize

Constructor Details

This class inherits a constructor from Pgai::Cli::Base

Instance Method Details

#addObject



20
21
22
# File 'lib/pgai/cli/env.rb', line 20

def add
  Pgai::Resources::Local::Environment.new(options).save
end

#dup(env) ⇒ Object



52
53
54
55
56
# File 'lib/pgai/cli/env.rb', line 52

def dup(env)
  env = Pgai::Resources::Local::Environment.find(env)
  attrs = env.attributes.merge(options.transform_keys(&:to_sym))
  Pgai::Resources::Local::Environment.new(attrs).save
end

#listObject



34
35
36
37
38
39
40
# File 'lib/pgai/cli/env.rb', line 34

def list
  data = Pgai::Resources::Local::Environment.all.map do |env|
    env.attributes.slice(:id, :alias, :port, :dbname, :snapshot)
  end

  say JSON.pretty_generate(data)
end

#removeObject



29
30
31
# File 'lib/pgai/cli/env.rb', line 29

def remove
  Pgai::Resources::Local::Environment.delete(options[:alias])
end