Class: Eien::CLI::Domains

Inherits:
CLI
  • Object
show all
Defined in:
lib/eien/cli/domains.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CLI

exit_on_failure?

Class Method Details

.domain_optionsObject



9
10
11
# File 'lib/eien/cli/domains.rb', line 9

def self.domain_options
  option(:enabled, type: :boolean)
end

Instance Method Details

#create(domain) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/eien/cli/domains.rb', line 75

def create(domain)
  rescue_and_exit do
    context = ::Eien.context_or_default(options[:context])
    app = ::Eien.app_or_default(options[:app])

    require_context!(context)
    require_app!(app)

    attributes = require_options(::Eien::Domains::UpdateTask::ALLOWED_ATTRIBUTES, {
      enabled: true,
    })

    ::Eien::Domains::CreateTask.new(
      context,
      app,
      domain,
      **attributes,
    ).run!
  end
end

#delete(domain) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/eien/cli/domains.rb', line 98

def delete(domain)
  rescue_and_exit do
    context = ::Eien.context_or_default(options[:context])
    app = ::Eien.app_or_default(options[:app])

    require_context!(context)
    require_app!(app)

    ::Eien::Domains::DeleteTask.new(
      context,
      app,
      domain,
    ).run!
  end
end

#disable(domain) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/eien/cli/domains.rb', line 52

def disable(domain)
  rescue_and_exit do
    context = ::Eien.context_or_default(options[:context])
    app = ::Eien.app_or_default(options[:app])

    require_context!(context)
    require_app!(app)

    ::Eien::Domains::UpdateTask.new(
      context,
      app,
      domain,
      enabled: false,
    ).run!
  end
end

#enable(domain) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/eien/cli/domains.rb', line 33

def enable(domain)
  rescue_and_exit do
    context = ::Eien.context_or_default(options[:context])
    app = ::Eien.app_or_default(options[:app])

    require_context!(context)
    require_app!(app)

    ::Eien::Domains::UpdateTask.new(
      context,
      app,
      domain,
      enabled: true,
    ).run!
  end
end

#listObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/eien/cli/domains.rb', line 16

def list
  rescue_and_exit do
    context = ::Eien.context_or_default(options[:context])
    app = ::Eien.app_or_default(options[:app])

    require_context!(context)
    require_app!(app)

    ::Eien::Domains::ListTask.new(
      context,
      app,
    ).run!
  end
end