lib/postfix_admin/runner.rb in postfix_admin-0.1.0 vs lib/postfix_admin/runner.rb in postfix_admin-0.1.1

- old
+ new

@@ -12,11 +12,11 @@ desc "summary [example.com]", "Summarize the usage of PostfixAdmin" def summary(domain_name=nil) runner{ @cli.show_summary(domain_name) } end - desc "show [example.com]", "List of domains" + desc "show [example.com | user@example.com]", "Show domains or mailboxes" def show(domain_name=nil) runner{ @cli.show(domain_name) } end desc "setup example.com password", "Setup a domain" @@ -43,10 +43,25 @@ desc "add_domain example.com", "Add a domain" def add_domain(domain_name) runner{ @cli.add_domain(domain_name) } end + desc "edit_domain example.com", "Edit a domain limitation" + method_option :aliases, :type => :numeric, :aliases => "-a", :desc => "Edit aliases limitation" + method_option :mailboxes, :type => :numeric, :aliases => "-m", :desc => "Edit mailboxes limitation" + method_option :maxquota, :type => :numeric, :aliases => "-q", :desc => "Edit max quota limitation" + 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 + desc "delete_domain example.com", "Delete a domain" def delete_domain(domain_name) runner{ @cli.delete_domain(domain_name) } end @@ -63,10 +78,23 @@ desc "add_account user@example.com password", "Add an account" def add_account(address, password) runner{ @cli.add_account(address, password) } end + desc "edit_account user@example.com", "Edit an account" + method_option :quota, :type => :numeric, :aliases => "-q", :desc => "Edit quota limitation" + def edit_account(address) + runner do + if options.size == 0 + warn "Use one or more options." + help('edit_account') + else + @cli.edit_account(address, options) + end + end + end + desc "add_admin admin@example.com password", "Add an admin user" method_option :super, :type => :boolean, :aliases => "-s", :desc => "register as a super admin" def add_admin(user_name, password) runner{ @cli.add_admin(user_name, password, options[:super]) } end @@ -74,10 +102,16 @@ desc "add_admin_domain admin@example.com example.com", "Add admin_domain" def add_admin_domain(user_name, domain_name) runner{ @cli.add_admin_domain(user_name, domain_name) } end + desc "delete_admin_domain admin@example.com example.com", "Delete admin_domain" + def delete_admin_domain(user_name, domain_name) + runner{ @cli.delete_admin_domain(user_name, domain_name) } + end + + desc "add_alias alias@example.com goto@example.net", "Add an alias" def add_alias(address, goto) runner{ @cli.add_alias(address, goto) } end @@ -87,18 +121,18 @@ end desc "version", "Show postfix_admin version" def version require 'postfix_admin/version' - say "postfix_admin #{VERSION}" + runner{ say "postfix_admin #{VERSION}" } end private def runner begin yield - rescue => e + rescue Error, ArgumentError => e warn e.message end end end end