Sha256: da2d0d027db279a0d8e6aad5207350dab13752aa247d4c9d9616855050c9ae4c

Contents?: true

Size: 706 Bytes

Versions: 14

Compression:

Stored size: 706 Bytes

Contents

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

  def initialize
    @name        = "add"
    @description = "Add a new contact"
  end

  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

14 entries across 14 versions & 1 rubygems

Version Path
ppl-1.5.2 lib/ppl/command/add.rb
ppl-1.5.1 lib/ppl/command/add.rb
ppl-1.5.0 lib/ppl/command/add.rb
ppl-1.4.1 lib/ppl/command/add.rb
ppl-1.3.0 lib/ppl/command/add.rb
ppl-1.2.0 lib/ppl/command/add.rb
ppl-1.1.0 lib/ppl/command/add.rb
ppl-1.0.6 lib/ppl/command/add.rb
ppl-1.0.5 lib/ppl/command/add.rb
ppl-1.0.4 lib/ppl/command/add.rb
ppl-1.0.3 lib/ppl/command/add.rb
ppl-1.0.1 lib/ppl/command/add.rb
ppl-1.0.0 lib/ppl/command/add.rb
ppl-0.9.0 lib/ppl/command/add.rb