Class: Devbin::Commands::Rails::Attach
- Inherits:
-
Devbin::Command
- Object
- Devbin::Command
- Devbin::Commands::Rails::Attach
- Defined in:
- lib/devbin/commands/rails/attach.rb
Instance Method Summary collapse
- #execute(input: $stdin, output: $stdout) ⇒ Object
-
#initialize(app_name, options) ⇒ Attach
constructor
A new instance of Attach.
Methods inherited from Devbin::Command
#command, #cursor, #docker_pwd, #docker_sync_pwd, #editor, #exec_exist?, #find_pwd, #generator, #pager, #pastel, #platform, #prompt, #screen, #which
Constructor Details
#initialize(app_name, options) ⇒ Attach
Returns a new instance of Attach.
9 10 11 12 |
# File 'lib/devbin/commands/rails/attach.rb', line 9 def initialize(app_name, ) @app_name = app_name @options = end |
Instance Method Details
#execute(input: $stdin, output: $stdout) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/devbin/commands/rails/attach.rb', line 14 def execute(input: $stdin, output: $stdout) container_id, _err = run "docker-compose ps -q #{@app_name}", chdir: docker_pwd puts pastel.green( "Remember to use ", pastel.yellow.on_bright_black.bold("Ctrl + C"), " to detach from container ( Overrided Ctrl + P Ctrl + Q to work with VSCode )" ) pid = Process.fork { exec "docker attach #{container_id.strip} --detach-keys='ctrl-c'" } Process.wait pid output.puts "OK" exit 0 end |