Class: VagrantPlugins::TrellisSequel::Command::Root

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant_plugins/trellis_sequel/command/root.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv, env) ⇒ Root

Returns a new instance of Root.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vagrant_plugins/trellis_sequel/command/root.rb', line 13

def initialize(argv, env)
  super

  @main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)

  @subcommands = Vagrant::Registry.new

  @subcommands.register(:open) do
    require_relative 'open'
    Open
  end
end

Class Method Details

.synopsisObject



9
10
11
# File 'lib/vagrant_plugins/trellis_sequel/command/root.rb', line 9

def self.synopsis
  'open Trellis databases in Sequel Pro'
end

Instance Method Details

#executeObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/vagrant_plugins/trellis_sequel/command/root.rb', line 26

def execute
  return help if help? || !sub_command?

  # Initialize and execute the command class
  @subcommands.get(@sub_command&.to_sym)
              .new(@sub_args, @env)
              .execute
rescue Vagrant::Errors::VagrantError => e
  raise e
rescue StandardError => e
  raise Vagrant::Errors::CLIInvalidUsage, help: "#{e.message}\r\n\r\nBacktrace:\r\n#{e.backtrace&.join("\r\n")}"
end