class Ppl::Command::Add

Attributes

name_service[W]

Public Instance Methods

execute(input, output) click to toggle source
# File lib/ppl/command/add.rb, line 12
def execute(input, output)
  contact_id   = input.arguments.shift
  contact_name = input.arguments.shift

  if contact_id.nil?
    raise Ppl::Error::IncorrectUsage, "No contact specified"
  end

  if contact_name.nil?
    raise Ppl::Error::IncorrectUsage, "No name specified"
  end

  contact = Ppl::Entity::Contact.new
  contact.id = contact_id.dup
  contact.name = @name_service.parse contact_name.dup

  @storage.save_contact(contact)
  return true
end
options(parser, options) click to toggle source
# File lib/ppl/command/add.rb, line 8
def options(parser, options)
  parser.banner = "usage: ppl add <contact> <name>"
end