Sha256: f347ba1a6351af7a986c4eb52612bded4e37e888d8d805fa29e47caead450f7b

Contents?: true

Size: 673 Bytes

Versions: 28

Compression:

Stored size: 673 Bytes

Contents

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

  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 = contact_name.dup

    @storage.save_contact(contact)
    return true
  end

end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
ppl-1.12.0 lib/ppl/command/add.rb
ppl-1.11.0 lib/ppl/command/add.rb
ppl-1.10.0 lib/ppl/command/add.rb
ppl-1.9.0 lib/ppl/command/add.rb
ppl-1.8.0 lib/ppl/command/add.rb
ppl-1.7.0 lib/ppl/command/add.rb
ppl-1.6.0 lib/ppl/command/add.rb
ppl-1.5.3 lib/ppl/command/add.rb