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

Defined Under Namespace

Classes: 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



18
19
20
21
22
23
24
25
26
# File 'lib/dip/cli.rb', line 18

def method_missing(cmd, *args)
  if Dip.config.interaction.key?(cmd.to_sym)
    args.unshift(cmd.to_s)
    args.unshift("run")
    self.class.start(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

Instance Method Details

#compose(cmd, *argv) ⇒ Object



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

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



57
58
59
# File 'lib/dip/cli.rb', line 57

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

#provisionObject



82
83
84
85
86
87
88
89
# File 'lib/dip/cli.rb', line 82

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)


28
29
30
# File 'lib/dip/cli.rb', line 28

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

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



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/dip/cli.rb', line 67

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

#up(*argv) ⇒ Object



52
53
54
# File 'lib/dip/cli.rb', line 52

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

#versionObject



33
34
35
36
# File 'lib/dip/cli.rb', line 33

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