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



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

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

#add_account(address, password) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/postfix_admin/runner.rb', line 86

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



140
141
142
143
144
145
146
147
148
149
# File 'lib/postfix_admin/runner.rb', line 140

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



152
153
154
# File 'lib/postfix_admin/runner.rb', line 152

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

#add_alias(address, goto) ⇒ Object



177
178
179
# File 'lib/postfix_admin/runner.rb', line 177

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

#add_domain(domain_name) ⇒ Object



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

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

#admin_passwd(user_name, password) ⇒ Object



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

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

#delete_account(address) ⇒ Object



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

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

#delete_admin(user_name) ⇒ Object



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

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

#delete_admin_domain(user_name, domain_name) ⇒ Object



157
158
159
# File 'lib/postfix_admin/runner.rb', line 157

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

#delete_alias(address) ⇒ Object



182
183
184
# File 'lib/postfix_admin/runner.rb', line 182

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

#delete_domain(domain_name) ⇒ Object



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

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

#dumpObject



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

def dump
  runner { @cli.dump }
end

#edit_account(address) ⇒ Object



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

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



126
127
128
129
130
131
132
133
134
135
# File 'lib/postfix_admin/runner.rb', line 126

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



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

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



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

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



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

def log
  runner { @cli.log }
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



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

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

#show(name = nil) ⇒ Object



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

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



197
198
199
200
# File 'lib/postfix_admin/runner.rb', line 197

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