Class: PostyClient::Command::DomainCommand
- Inherits:
-
Thor
- Object
- Thor
- PostyClient::Command::DomainCommand
- Defined in:
- lib/posty_client/command/domain_command.rb
Instance Method Summary collapse
- #add(name) ⇒ Object
- #delete(name) ⇒ Object
- #list ⇒ Object
- #rename(name, new_name) ⇒ Object
- #show(domain_name) ⇒ Object
Instance Method Details
#add(name) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/posty_client/command/domain_command.rb', line 37 def add(name) domain = PostyClient::Resources::Domain.new(name) unless domain.save say domain.errors.inspect, :red exit 1 end end |
#delete(name) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/posty_client/command/domain_command.rb', line 57 def delete(name) if yes?("Delete #{name}?") domain = PostyClient::Resources::Domain.new(name) unless domain.delete say domain.errors.inspect, :red exit 1 end end end |
#list ⇒ Object
31 32 33 34 |
# File 'lib/posty_client/command/domain_command.rb', line 31 def list domains = PostyClient::Resources::Domain.all.map {|d| [d.name]} print_table(domains) end |
#rename(name, new_name) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/posty_client/command/domain_command.rb', line 47 def rename(name, new_name) domain = PostyClient::Resources::Domain.new(name) domain.attributes['name'] = new_name unless domain.save say domain.errors.inspect, :red exit 1 end end |
#show(domain_name) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/posty_client/command/domain_command.rb', line 5 def show(domain_name) domain = PostyClient::Resources::Domain.new(domain_name) if domain.new_resource? say "Unknown domain '#{domain.name}'", :red exit 1 else say("#{domain.name}:") shell.indent do say("users:") shell.indent do domain.users.each do say "- #{_1.name}" end end say("aliases:") shell.indent do domain.aliases.each do say "- #{_1.name}" end end end end end |