Class: Dip::CLI
- Inherits:
-
Thor
show all
- Defined in:
- lib/dip/cli.rb,
lib/dip/cli/dns.rb,
lib/dip/cli/ssh.rb,
lib/dip/cli/base.rb,
lib/dip/cli/infra.rb,
lib/dip/cli/console.rb
Defined Under Namespace
Classes: Base, Console, DNS, Infra, SSH
Constant Summary
collapse
- TOP_LEVEL_COMMANDS =
%w[help version ls compose up stop down run provision ssh infra console validate]
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
18
19
20
|
# File 'lib/dip/cli.rb', line 18
def exit_on_failure?
true
end
|
.is_thor_reserved_word?(word, type) ⇒ Boolean
Hackery. Take the run method away from Thor so that we can redefine it.
12
13
14
15
16
|
# File 'lib/dip/cli.rb', line 12
def is_thor_reserved_word?(word, type)
return false if word == "run"
super
end
|
Instance Method Details
#build(*argv) ⇒ Object
60
61
62
|
# File 'lib/dip/cli.rb', line 60
def build(*argv)
compose("build", *argv)
end
|
#down(*argv) ⇒ Object
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/dip/cli.rb', line 77
def down(*argv)
if options[:help]
invoke :help, ["down"]
elsif options[:all]
require_relative "commands/down_all"
Dip::Commands::DownAll.new.execute
else
compose("down", *argv.push("--remove-orphans"))
end
end
|
#ls ⇒ Object
45
46
47
48
|
# File 'lib/dip/cli.rb', line 45
def ls
require_relative "commands/list"
Dip::Commands::List.new.execute
end
|
#provision ⇒ Object
119
120
121
122
123
124
125
126
|
# File 'lib/dip/cli.rb', line 119
def provision
if options[:help]
invoke :help, ["provision"]
else
require_relative "commands/provision"
Dip::Commands::Provision.new.execute
end
end
|
#run(*argv) ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/dip/cli.rb', line 101
def run(*argv)
if argv.empty? || options[:help]
invoke :help, ["run"]
else
require_relative "commands/preflight"
require_relative "commands/run"
Dip::Commands::Preflight.new.execute
Dip::Commands::Run.new(
*argv,
**options.to_h.transform_keys!(&:to_sym)
).execute
end
end
|
#stop(*argv) ⇒ Object
70
71
72
|
# File 'lib/dip/cli.rb', line 70
def stop(*argv)
compose("stop", *argv)
end
|
#up(*argv) ⇒ Object
65
66
67
|
# File 'lib/dip/cli.rb', line 65
def up(*argv)
compose("up", *argv)
end
|
#validate ⇒ Object
129
130
131
132
133
134
135
|
# File 'lib/dip/cli.rb', line 129
def validate
Dip.config.validate
puts "dip.yml is valid"
rescue Dip::Error => e
warn "Validation failed: #{e.message}"
exit 1
end
|
#version ⇒ Object
38
39
40
41
|
# File 'lib/dip/cli.rb', line 38
def version
require_relative "version"
puts Dip::VERSION
end
|