Sha256: 632dc34d492ad7619f9d9c5673ef33fb0156d092b7792c4097f49b0f4ae04473

Contents?: true

Size: 722 Bytes

Versions: 10

Compression:

Stored size: 722 Bytes

Contents

class Ppl::Command::Add < Ppl::Application::Command

  attr_writer :name_service

  name        "add"
  description "Add a new contact"

  def options(parser, options)
    parser.banner = "usage: ppl add <contact> <name>"
  end

  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

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ppl-3.0.1 lib/ppl/command/add.rb
ppl-3.0.0 lib/ppl/command/add.rb
ppl-2.4.1 lib/ppl/command/add.rb
ppl-2.4.0 lib/ppl/command/add.rb
ppl-2.3.3 lib/ppl/command/add.rb
ppl-2.3.2 lib/ppl/command/add.rb
ppl-2.3.1 lib/ppl/command/add.rb
ppl-2.3.0 lib/ppl/command/add.rb
ppl-2.2.0 lib/ppl/command/add.rb
ppl-2.1.0 lib/ppl/command/add.rb