Class: DokkuCli::Cli
- Inherits:
-
Thor
- Object
- Thor
- DokkuCli::Cli
show all
- Defined in:
- lib/dokku_cli.rb,
lib/dokku_cli/ps.rb,
lib/dokku_cli/nginx.rb,
lib/dokku_cli/config.rb,
lib/dokku_cli/domains.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
63
64
65
66
67
68
69
70
71
|
# File 'lib/dokku_cli.rb', line 63
def method_missing(method, *args, &block)
if method.to_s.split(":").length >= 2
self.send(method.to_s.gsub(":", "_"), *args)
elsif method == :run
self.walk(*args)
else
super
end
end
|
Instance Method Details
#config ⇒ Object
5
6
7
|
# File 'lib/dokku_cli/config.rb', line 5
def config
run_command "config #{app_name}"
end
|
#config_get(key) ⇒ Object
10
11
12
|
# File 'lib/dokku_cli/config.rb', line 10
def config_get(key)
run_command "config:get #{app_name} #{key}"
end
|
#config_set(*args) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/dokku_cli/config.rb', line 15
def config_set(*args)
user = "dokku"
args = args.map{|arg|
key_value = arg.split("=")
if key_value.length == 2
if key_value[1].index(" ")
user = "root"
return_value = "#{key_value[0]}="
return_value += '\"'
return_value += key_value[1].gsub(/"|'/, "")
return_value += '\"'
return_value
else
"#{key_value[0]}=#{key_value[1].gsub(/"|'/, "")}"
end
else
arg
end
}
command = "ssh #{user}@#{domain} "
command += user == "root" ? "dokku " : ""
command += "config:set #{app_name} #{args.join(' ')}"
puts "Running #{command}..."
exec(command)
end
|
#config_set_file(config_file) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/dokku_cli/config.rb', line 51
def config_set_file(config_file)
config_params = ""
if File.exists?(config_file)
File.open(config_file).each_line do |line|
config_params += line.strip + " " unless line.start_with? "#" || line.strip == ""
end
config_set(config_params)
else
puts "File #{config_file} does not exist."
end
end
|
#config_unset(*args) ⇒ Object
46
47
48
|
# File 'lib/dokku_cli/config.rb', line 46
def config_unset(*args)
run_command "config:unset #{app_name} #{args.join(' ')}"
end
|
#domains ⇒ Object
5
6
7
|
# File 'lib/dokku_cli/domains.rb', line 5
def domains
run_command "domains #{app_name}"
end
|
#domains_add(custom_domain) ⇒ Object
10
11
12
|
# File 'lib/dokku_cli/domains.rb', line 10
def domains_add(custom_domain)
run_command "domains:add #{app_name} #{custom_domain}"
end
|
#domains_clear ⇒ Object
15
16
17
|
# File 'lib/dokku_cli/domains.rb', line 15
def domains_clear
run_command "domains:clear #{app_name}"
end
|
#domains_remove(custom_domain) ⇒ Object
20
21
22
|
# File 'lib/dokku_cli/domains.rb', line 20
def domains_remove(custom_domain)
run_command "domains:remove #{app_name} #{custom_domain}"
end
|
#help(method = nil) ⇒ Object
58
59
60
61
|
# File 'lib/dokku_cli.rb', line 58
def help(method = nil)
method = "walk" if method == "run"
super
end
|
#logs(*args) ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'lib/dokku_cli.rb', line 12
def logs(*args)
if args.first && args.first.strip == "-t"
command = "ssh dokku@#{domain} logs #{app_name} -t"
puts "Running #{command}..."
exec(command)
else
run_command "logs #{app_name}"
end
end
|
#nginx_build ⇒ Object
5
6
7
|
# File 'lib/dokku_cli/nginx.rb', line 5
def nginx_build
run_command "nginx:build-config #{app_name}"
end
|
#open ⇒ Object
23
24
25
26
|
# File 'lib/dokku_cli.rb', line 23
def open
url = %x[dokku urls].split("\r").first
exec("open #{url}")
end
|
#ps ⇒ Object
5
6
7
|
# File 'lib/dokku_cli/ps.rb', line 5
def ps
run_command "ps #{app_name}"
end
|
#ps_rebuild ⇒ Object
10
11
12
|
# File 'lib/dokku_cli/ps.rb', line 10
def ps_rebuild
run_command "ps:rebuild #{app_name}"
end
|
#ps_restart ⇒ Object
15
16
17
|
# File 'lib/dokku_cli/ps.rb', line 15
def ps_restart
run_command "ps:restart #{app_name}"
end
|
#ps_start ⇒ Object
20
21
22
|
# File 'lib/dokku_cli/ps.rb', line 20
def ps_start
run_command "ps:start #{app_name}"
end
|
#ssh ⇒ Object
42
43
44
45
46
|
# File 'lib/dokku_cli.rb', line 42
def ssh
command = "ssh root@#{domain}"
puts "Running #{command}..."
exec(command)
end
|
#url ⇒ Object
49
50
51
|
# File 'lib/dokku_cli.rb', line 49
def url
run_command "url #{app_name}"
end
|
#urls ⇒ Object
54
55
56
|
# File 'lib/dokku_cli.rb', line 54
def urls
run_command "urls #{app_name}"
end
|
#walk(*args) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/dokku_cli.rb', line 29
def walk(*args)
command = "#{args.join(' ')}"
case command.gsub(" ", "")
when "rakedb:drop"
puts "You cannot use `rake db:drop`. Use Dokku directly to delete the database."
when "rakedb:create"
puts "You cannot use `rake db:create`. Use Dokku directly to create the database."
else
run_command "run #{app_name} #{command}"
end
end
|