Skip to content

Commit 0ec56e9

Browse files
committed
Allow passing arguments to console subcommand
The `console` subcommand can't take arguments, which prevents the easy use of the `--sandbox` feature on staging and production consoles to check things with confidence that production data isn't being accidentally changed. This change appends post-`console` arguments as arguments on Heroku.
1 parent 565d114 commit 0ec56e9

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/parity/environment.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ def from_development?
8989
end
9090

9191
def console
92-
Kernel.system(command_for_remote("run bundle exec rails console"))
92+
Kernel.system(
93+
command_for_remote(
94+
"run bundle exec rails console #{arguments.join(' ')}",
95+
),
96+
)
9397
end
9498

9599
def migrate

spec/parity/environment_spec.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@
162162
expect(Kernel).to have_received(:system).with(heroku_console)
163163
end
164164

165+
it "passes arguments to the console subcommand" do
166+
Parity::Environment.new("production", ["console", "--sandbox"]).run
167+
168+
expect(Kernel).to have_received(:system).with(heroku_console_with_sandbox)
169+
end
170+
165171
it "automatically restarts processes when it migrates the database" do
166172
Parity::Environment.new("production", ["migrate"]).run
167173

@@ -221,7 +227,11 @@ def heroku_backup
221227
end
222228

223229
def heroku_console
224-
"heroku run bundle exec rails console --remote production"
230+
"heroku run bundle exec rails console --remote production"
231+
end
232+
233+
def heroku_console_with_sandbox
234+
"heroku run bundle exec rails console --sandbox --remote production"
225235
end
226236

227237
def git_push

0 commit comments

Comments
 (0)