Class: GDKBox::VSCode

Inherits:
Object
  • Object
show all
Defined in:
lib/gdkbox/vscode.rb

Overview

Bridges a box to VS Code's Remote-SSH support.

Because each box already has a Host gdkbox-<name> entry in the generated SSH config, opening it is just a matter of pointing the code CLI at the matching ssh-remote+ authority.

Instance Method Summary collapse

Constructor Details

#initialize(shell: Shell.new) ⇒ VSCode

Returns a new instance of VSCode.



10
11
12
# File 'lib/gdkbox/vscode.rb', line 10

def initialize(shell: Shell.new)
  @shell = shell
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/gdkbox/vscode.rb', line 14

def available?
  !@shell.which("code").nil?
end

#open(box) ⇒ Object



22
23
24
# File 'lib/gdkbox/vscode.rb', line 22

def open(box)
  @shell.run!(*open_command(box))
end

#open_command(box) ⇒ Object



18
19
20
# File 'lib/gdkbox/vscode.rb', line 18

def open_command(box)
  ["code", "--remote", "ssh-remote+#{box.ssh_host_alias}", box.remote_path]
end