Class: Ppl::Command::Ls

Inherits:
Application::Command show all
Defined in:
lib/ppl/command/ls.rb

Instance Attribute Summary collapse

Attributes inherited from Application::Command

#storage

Instance Method Summary collapse

Methods inherited from Application::Command

add_property

Instance Attribute Details

#custom_format=(value) ⇒ Object (writeonly)

Sets the attribute custom_format

Parameters:

  • value

    the value to set the attribute custom_format to.



8
9
10
# File 'lib/ppl/command/ls.rb', line 8

def custom_format=(value)
  @custom_format = value
end

#default_format=(value) ⇒ Object (writeonly)

Sets the attribute default_format

Parameters:

  • value

    the value to set the attribute default_format to.



7
8
9
# File 'lib/ppl/command/ls.rb', line 7

def default_format=(value)
  @default_format = value
end

Instance Method Details

#execute(input, output) ⇒ Object



20
21
22
23
24
25
# File 'lib/ppl/command/ls.rb', line 20

def execute(input, output)
  address_book = @storage.load_address_book
  formatted    = format_address_book(address_book, input.options)
  output.line(formatted)
  true
end

#options(parser, options) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/ppl/command/ls.rb', line 10

def options(parser, options)
  parser.banner = "usage: ppl ls"
  parser.on("--format <format>", "specify a custom output format") do |format|
    options[:format] = format
  end
  parser.on("--pretty <format>", "specify a custom output format") do |pretty|
    options[:pretty] = pretty
  end
end