Class: Runoff::Commandline::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/runoff/commandline/command.rb

Overview

Public: A base class for all runoff commands except None.

Should be used only by inheriting.

Direct Known Subclasses

All, Some

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#parserObject (readonly)

Public: Returns an OptionParser object



14
15
16
# File 'lib/runoff/commandline/command.rb', line 14

def parser
  @parser
end

Instance Method Details

#execute(args) {|chat, file_writer| ... } ⇒ Object

Public: executes the command.

args - An Array of commandline arguments.

Yields:

  • (chat, file_writer)


19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/runoff/commandline/command.rb', line 19

def execute(args)
  puts 'Exporting...'.colorize :green

  db_location = Location.get_database_path args, @options
  chat = Chat.new db_location, @options
  file_writer = FileWriter.new @options

  yield chat, file_writer if block_given?

  file_writer.archive if @options[:archive]

  puts 'Finished.'.colorize :green
end