Class: Dip::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/dip/cli.rb,
lib/dip/cli/dns.rb,
lib/dip/cli/ssh.rb,
lib/dip/cli/nginx.rb,
lib/dip/cli/console.rb

Defined Under Namespace

Classes: Console, DNS, Nginx, SSH

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(cmd, *args) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/dip/cli.rb', line 22

def method_missing(cmd, *args)
  if Dip.config.interaction.key?(cmd.to_sym)
    self.class.start(["run", cmd] + args)
  else
    super
  end
end

Class Method Details

.is_thor_reserved_word?(word, type) ⇒ Boolean

Hackery. Take the run method away from Thor so that we can redefine it.

Returns:

  • (Boolean)


9
10
11
12
13
# File 'lib/dip/cli.rb', line 9

def is_thor_reserved_word?(word, type)
  return false if word == "run"

  super
end

.start(argv) ⇒ Object



15
16
17
# File 'lib/dip/cli.rb', line 15

def start(argv)
  super Dip::RunVars.call(argv, ENV)
end

Instance Method Details

#compose(cmd, *argv) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/dip/cli.rb', line 44

def compose(cmd, *argv)
  if options[:help]
    invoke :help, ['compose']
  else
    require_relative 'commands/compose'
    Dip::Commands::Compose.new(cmd, argv).execute
  end
end

#down(*argv) ⇒ Object



59
60
61
# File 'lib/dip/cli.rb', line 59

def down(*argv)
  compose("down", *argv)
end

#provisionObject



78
79
80
81
82
83
84
85
# File 'lib/dip/cli.rb', line 78

def provision
  if options[:help]
    invoke :help, ['provision']
  else
    require_relative 'commands/provision'
    Dip::Commands::Provision.new.execute
  end
end

#respond_to_missing?(cmd) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/dip/cli.rb', line 30

def respond_to_missing?(cmd)
  Dip.config.interaction.key?(cmd.to_sym)
end

#run(cmd, subcmd = nil, *argv) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/dip/cli.rb', line 66

def run(cmd, subcmd = nil, *argv)
  if options[:help]
    invoke :help, ['run']
  else
    require_relative 'commands/run'
    Dip::Commands::Run.new(cmd, subcmd, argv).execute
  end
end

#up(*argv) ⇒ Object



54
55
56
# File 'lib/dip/cli.rb', line 54

def up(*argv)
  compose("up", *argv)
end

#versionObject



35
36
37
38
# File 'lib/dip/cli.rb', line 35

def version
  require_relative 'version'
  puts Dip::VERSION
end