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



92
93
94
95
96
97
# File 'lib/postfix_admin/runner.rb', line 92

def (user_name, password)
  runner do
    @cli.(user_name, password,
                                 scheme: options[:scheme], rounds: options[:rounds])
  end
end

#accountsObject



44
45
46
# File 'lib/postfix_admin/runner.rb', line 44

def accounts
  runner { @cli.show_accounts }
end

#add_account(address, password) ⇒ Object



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/postfix_admin/runner.rb', line 141

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, name: options[:name],
                         scheme: options[:scheme], rounds: options[:rounds])
      end
    end
  end
end

#add_admin(user_name, password) ⇒ Object



201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/postfix_admin/runner.rb', line 201

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,
                     super_admin: options[:super], scheme: options[:scheme],
                     rounds: options[:rounds])
    end
  end
end

#add_admin_domain(user_name, domain_name) ⇒ Object



216
217
218
# File 'lib/postfix_admin/runner.rb', line 216

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

#add_alias(address, goto) ⇒ Object



242
243
244
# File 'lib/postfix_admin/runner.rb', line 242

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

#add_domain(domain_name) ⇒ Object



101
102
103
# File 'lib/postfix_admin/runner.rb', line 101

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

#admin_passwd(user_name, password) ⇒ Object



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

def admin_passwd(user_name, password)
  runner do
    @cli.change_admin_password(user_name, password,
                               scheme: options[:scheme], rounds: options[:rounds])
  end
end

#adminsObject



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

def admins
  runner { @cli.show_admins }
end

#aliasesObject



49
50
51
# File 'lib/postfix_admin/runner.rb', line 49

def aliases
  runner { @cli.show_aliases }
end

#delete_account(address) ⇒ Object



133
134
135
# File 'lib/postfix_admin/runner.rb', line 133

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

#delete_admin(user_name) ⇒ Object



128
129
130
# File 'lib/postfix_admin/runner.rb', line 128

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

#delete_admin_domain(user_name, domain_name) ⇒ Object



222
223
224
# File 'lib/postfix_admin/runner.rb', line 222

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

#delete_alias(address) ⇒ Object



247
248
249
# File 'lib/postfix_admin/runner.rb', line 247

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

#delete_domain(domain_name) ⇒ Object



123
124
125
# File 'lib/postfix_admin/runner.rb', line 123

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

#domainsObject



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

def domains
  runner { @cli.show_domains }
end

#dumpObject



259
260
261
# File 'lib/postfix_admin/runner.rb', line 259

def dump
  runner { @cli.dump }
end

#edit_account(address) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/postfix_admin/runner.rb', line 167

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



186
187
188
189
190
191
192
193
194
195
# File 'lib/postfix_admin/runner.rb', line 186

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



230
231
232
233
234
235
236
237
238
239
# File 'lib/postfix_admin/runner.rb', line 230

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



111
112
113
114
115
116
117
118
119
120
# File 'lib/postfix_admin/runner.rb', line 111

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

#forwardsObject



54
55
56
# File 'lib/postfix_admin/runner.rb', line 54

def forwards
  runner { @cli.show_forwards }
end

#logObject



254
255
256
# File 'lib/postfix_admin/runner.rb', line 254

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



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

def setup(domain_name, password)
  runner do
    @cli.setup_domain(domain_name, password,
                      description: options[:description],
                      scheme: options[:scheme], rounds: options[:rounds])
  end
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

#teardown(domain_name) ⇒ Object



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

def teardown(domain_name)
  runner { @cli.teardown_domain(domain_name) }
end

#versionObject



264
265
266
267
# File 'lib/postfix_admin/runner.rb', line 264

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