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-2.0.0 lib/ppl/command/add.rb
ppl-1.25.0 lib/ppl/command/add.rb
ppl-1.24.0 lib/ppl/command/add.rb
ppl-1.23.0 lib/ppl/command/add.rb
ppl-1.22.2 lib/ppl/command/add.rb
ppl-1.22.1 lib/ppl/command/add.rb
ppl-1.22.0 lib/ppl/command/add.rb
ppl-1.21.0 lib/ppl/command/add.rb
ppl-1.20.0 lib/ppl/command/add.rb
ppl-1.19.0 lib/ppl/command/add.rb
ppl-1.18.0 lib/ppl/command/add.rb
ppl-1.17.2 lib/ppl/command/add.rb
ppl-1.17.1 lib/ppl/command/add.rb
ppl-1.17.0 lib/ppl/command/add.rb
ppl-1.16.0 lib/ppl/command/add.rb
ppl-1.15.1 lib/ppl/command/add.rb
ppl-1.15.0 lib/ppl/command/add.rb
ppl-1.14.1 lib/ppl/command/add.rb
ppl-1.14.0 lib/ppl/command/add.rb
ppl-1.13.0 lib/ppl/command/add.rb