Class: PostfixAdmin::Runner

Inherits:
Thor
  • Object
show all
Defined in:
lib/postfix_admin/runner.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Runner

Returns a new instance of Runner.



12
13
14
15
# File 'lib/postfix_admin/runner.rb', line 12

def initialize(*args)
  super
  @cli = CLI.new
end

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/postfix_admin/runner.rb', line 8

def self.exit_on_failure?
  true
end

Instance Method Details

#account_passwd(user_name, password) ⇒ Object



46
47
48
# File 'lib/postfix_admin/runner.rb', line 46

def (user_name, password)
  runner { @cli.(user_name, password) }
end

#add_account(address, password) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/postfix_admin/runner.rb', line 91

def (address, password)
  runner do
    if options[:scheme] == 'scheme'
      warn "Specify password scheme"
      help('add_account')
    else
      if options[:name] == 'name'
        warn "Specify name"
        help('add_account')
      else
        @cli.(address, password, options[:scheme], options[:name])
      end
    end
  end
end

#add_admin(user_name, password) ⇒ Object



149
150
151
152
153
154
155
156
157
158
# File 'lib/postfix_admin/runner.rb', line 149

def add_admin(user_name, password)
  runner do
    if options[:scheme] == 'scheme'
      warn "Specify password scheme"
      help('add_admin')
    else
      @cli.add_admin(user_name, password, options[:super], options[:scheme])
    end
  end
end

#add_admin_domain(user_name, domain_name) ⇒ Object



162
163
164
# File 'lib/postfix_admin/runner.rb', line 162

def add_admin_domain(user_name, domain_name)
  runner { @cli.add_admin_domain(user_name, domain_name) }
end

#add_alias(address, goto) ⇒ Object



188
189
190
# File 'lib/postfix_admin/runner.rb', line 188

def add_alias(address, goto)
  runner { @cli.add_alias(address, goto) }
end

#add_domain(domain_name) ⇒ Object



52
53
54
# File 'lib/postfix_admin/runner.rb', line 52

def add_domain(domain_name)
  runner { @cli.add_domain(domain_name, description: options[:description]) }
end

#admin_passwd(user_name, password) ⇒ Object



40
41
42
# File 'lib/postfix_admin/runner.rb', line 40

def admin_passwd(user_name, password)
  runner { @cli.change_admin_password(user_name, password) }
end

#delete_account(address) ⇒ Object



84
85
86
# File 'lib/postfix_admin/runner.rb', line 84

def (address)
  runner { @cli.(address) }
end

#delete_admin(user_name) ⇒ Object



79
80
81
# File 'lib/postfix_admin/runner.rb', line 79

def delete_admin(user_name)
  runner { @cli.delete_admin(user_name) }
end

#delete_admin_domain(user_name, domain_name) ⇒ Object



168
169
170
# File 'lib/postfix_admin/runner.rb', line 168

def delete_admin_domain(user_name, domain_name)
  runner { @cli.delete_admin_domain(user_name, domain_name) }
end

#delete_alias(address) ⇒ Object



193
194
195
# File 'lib/postfix_admin/runner.rb', line 193

def delete_alias(address)
  runner { @cli.delete_alias(address) }
end

#delete_domain(domain_name) ⇒ Object



74
75
76
# File 'lib/postfix_admin/runner.rb', line 74

def delete_domain(domain_name)
  runner { @cli.delete_domain(domain_name) }
end

#dumpObject



205
206
207
# File 'lib/postfix_admin/runner.rb', line 205

def dump
  runner { @cli.dump }
end

#edit_account(address) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/postfix_admin/runner.rb', line 116

def (address)
  runner do
    if options.size == 0
      warn "Use one or more options."
      help('edit_account')
    else
      if options[:name] == 'name'
        warn "Specify name"
        help('edit_account')
      else
        @cli.(address, options)
      end
    end
  end
end

#edit_admin(user_name) ⇒ Object



135
136
137
138
139
140
141
142
143
144
# File 'lib/postfix_admin/runner.rb', line 135

def edit_admin(user_name)
  runner do
    if options.size == 0
      warn "Use one or more options."
      help('edit_admin')
    else
      @cli.edit_admin(user_name, options)
    end
  end
end

#edit_alias(address) ⇒ Object



176
177
178
179
180
181
182
183
184
185
# File 'lib/postfix_admin/runner.rb', line 176

def edit_alias(address)
  runner do
    if options.size == 0
      warn "Use one or more options."
      help('edit_alias')
    else
      @cli.edit_alias(address, options)
    end
  end
end

#edit_domain(domain_name) ⇒ Object



62
63
64
65
66
67
68
69
70
71
# File 'lib/postfix_admin/runner.rb', line 62

def edit_domain(domain_name)
  runner do
    if options.size == 0
      warn "Use one or more options."
      help('edit_domain')
    else
      @cli.edit_domain(domain_name, options)
    end
  end
end

#logObject



200
201
202
# File 'lib/postfix_admin/runner.rb', line 200

def log
  runner { @cli.log(domain: options[:domain], last: options[:last]) }
end

#schemesObject



23
24
25
# File 'lib/postfix_admin/runner.rb', line 23

def schemes
  runner { puts PostfixAdmin::Doveadm.schemes.join(' ') }
end

#setup(domain_name, password) ⇒ Object



34
35
36
# File 'lib/postfix_admin/runner.rb', line 34

def setup(domain_name, password)
  runner { @cli.setup_domain(domain_name, password) }
end

#show(name = nil) ⇒ Object



29
30
31
# File 'lib/postfix_admin/runner.rb', line 29

def show(name = nil)
  runner { @cli.show(name) }
end

#summary(domain_name = nil) ⇒ Object



18
19
20
# File 'lib/postfix_admin/runner.rb', line 18

def summary(domain_name = nil)
  runner { @cli.show_summary(domain_name) }
end

#versionObject



210
211
212
213
# File 'lib/postfix_admin/runner.rb', line 210

def version
  require 'postfix_admin/version'
  runner { say "postfix_admin #{VERSION}" }
end