Class: Boxd::DevCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/boxd/dev_command.rb

Overview

Implements the ‘boxd-dev` command. Given a repo reference, ensures a dev VM exists for it (forked from a golden), the repo is cloned and set up, a persistent tmux session is running, then drops you into it over SSH.

Repo references accepted:

chad/phoenix                                  # GitHub (by convention)
github.com/chad/phoenix
https://github.com/chad/phoenix(.git)?
git@github.com:chad/phoenix.git
https://gitlab.com/group/proj
<bare VM name>                                # connect to existing

Constant Summary collapse

GOLDEN_DEFAULT =
"dev-golden"
BOOTSTRAP_LOCAL =
File.expand_path("dev_bootstrap.sh", __dir__)
BOOTSTRAP_REMOTE =
"/tmp/dev-bootstrap"

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ DevCommand

Returns a new instance of DevCommand.



26
27
28
# File 'lib/boxd/dev_command.rb', line 26

def initialize(argv)
  @argv = argv
end

Instance Method Details

#runObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/boxd/dev_command.rb', line 30

def run
  do_run
rescue Boxd::CLIMissingError => e
  warn e.message
  exit 1
rescue Boxd::AuthenticationError
  warn <<~MSG
    boxd-dev: you're not logged in to boxd yet.

      Run:  boxd login

    (or set BOXD_TOKEN to a long-lived API key from `boxd keys create`)
  MSG
  exit 1
rescue Boxd::Error => e
  warn "boxd-dev: #{e.message}"
  exit 1
end