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



88
89
90
91
92
93
# File 'lib/postfix_admin/runner.rb', line 88

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



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/postfix_admin/runner.rb', line 137

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



197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/postfix_admin/runner.rb', line 197

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



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

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

#add_alias(address, goto) ⇒ Object



238
239
240
# File 'lib/postfix_admin/runner.rb', line 238

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

#add_domain(domain_name) ⇒ Object



97
98
99
# File 'lib/postfix_admin/runner.rb', line 97

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

#admin_passwd(user_name, password) ⇒ Object



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

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



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

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

#delete_admin(user_name) ⇒ Object



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

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

#delete_admin_domain(user_name, domain_name) ⇒ Object



218
219
220
# File 'lib/postfix_admin/runner.rb', line 218

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

#delete_alias(address) ⇒ Object



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

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

#delete_domain(domain_name) ⇒ Object



119
120
121
# File 'lib/postfix_admin/runner.rb', line 119

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



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

def dump
  runner { @cli.dump }
end

#edit_account(address) ⇒ Object



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/postfix_admin/runner.rb', line 163

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



182
183
184
185
186
187
188
189
190
191
# File 'lib/postfix_admin/runner.rb', line 182

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



226
227
228
229
230
231
232
233
234
235
# File 'lib/postfix_admin/runner.rb', line 226

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



107
108
109
110
111
112
113
114
115
116
# File 'lib/postfix_admin/runner.rb', line 107

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



250
251
252
# File 'lib/postfix_admin/runner.rb', line 250

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



61
62
63
64
65
66
# File 'lib/postfix_admin/runner.rb', line 61

def setup(domain_name, password)
  runner do
    @cli.setup_domain(domain_name, password,
                      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



69
70
71
# File 'lib/postfix_admin/runner.rb', line 69

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

#versionObject



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

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