pgai 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbd22b8be81c76ea9a661cd5b9f0befffeade51768c562bdfa9991f84e998401
4
- data.tar.gz: 9281676b174a9553b6a1042f787c8f00510f25e117c6736ce3a5f4a8bf79a0c1
3
+ metadata.gz: 638625e64ce9fa8f81c98f8a618b74f3d9f1e7ae14632bb4994a581011ad4bf3
4
+ data.tar.gz: 4703d7e923b428ac933f72335af104b373b991d048abef7516248983d8dcfb25
5
5
  SHA512:
6
- metadata.gz: a2d1852ef9c05a0827f35c1af73b3e805578cd849010dc679f2796f46eae454c468051ba4d9128e25477c5096de595f8126bc2da0540fa307351fca8eefde250
7
- data.tar.gz: e4eb38d1c0dce730db90ef99b7396e06536c193c17e41e840cd48a908f14fc684573c3d250ca8821d57086a8bc6956c5663386093a0452c61e749feede460908
6
+ metadata.gz: f05388f1e73e3277a06baea0298bafd175a8e50959e3a0fe9580e099820e84bd13e1665c9f8841b0e46f437fea638728a11c510c332026834fa399144394b022
7
+ data.tar.gz: dd1c62be57dd6fa39a4b9b685f390072eb6e51ebb9dc7a10627c7366ddf89521e9edca73b17def3e178d36108c889466e6ca95a038cb121635092084c7ff8646
data/lib/pgai/cli/main.rb CHANGED
@@ -40,6 +40,21 @@ module Pgai::Cli
40
40
  print_table data
41
41
  end
42
42
 
43
+ desc "use", "Execute the given command with DATABASE_URLs"
44
+ method_option :only, aliases: "-o", desc: "Export only this database connection", repeatable: true
45
+ def use(*command)
46
+ envs = options.fetch(:only) { configuration.enviroments.keys }
47
+
48
+ vars = envs.each_with_object({}) do |env, acc|
49
+ environment = configuration.enviroments.fetch(env)
50
+ clone = Pgai::CloneManager.new(environment, config: configuration).clone
51
+
52
+ acc["#{env.to_s.upcase}_DATABASE_URL"] = clone.database_url
53
+ end
54
+
55
+ exec(vars, *command)
56
+ end
57
+
43
58
  desc "env", "Manage environments"
44
59
  subcommand "env", Pgai::Cli::Env
45
60
  end
@@ -51,6 +51,13 @@ module Pgai
51
51
  }
52
52
  end
53
53
 
54
+ def clone
55
+ configure_enviroment
56
+ clone = find_or_create_clone
57
+ port_forward.start(clone.port)
58
+ clone
59
+ end
60
+
54
61
  private
55
62
 
56
63
  attr_reader :environment, :config, :port_forward, :dblab
data/lib/pgai/config.rb CHANGED
@@ -72,7 +72,7 @@ module Pgai
72
72
 
73
73
  def persist_clone(id, attributes = {})
74
74
  store.transaction do
75
- store[:clones] = {}
75
+ store[:clones] ||= {}
76
76
  store[:clones].merge!(id => attributes)
77
77
  end
78
78
 
data/lib/pgai/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pgai
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marius Bobin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-18 00:00:00.000000000 Z
11
+ date: 2023-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor