Class: BrewOutdatedFormatter::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/brew_outdated_formatter/cli.rb

Overview

Command-line interface of BrewOutdatedFormatter

Constant Summary collapse

FORMATTERS =
{
  'terminal' => TerminalFormatter,
  'markdown' => MarkdownFormatter,
  'json'     => JSONFormatter,
  'yaml'     => YAMLFormatter,
  'csv'      => CSVFormatter,
  'tsv'      => TSVFormatter,
  'xml'      => XMLFormatter,
  'html'     => HTMLFormatter
}.freeze

Instance Method Summary collapse

Instance Method Details

#outputObject



32
33
34
35
36
37
38
39
# File 'lib/brew_outdated_formatter/cli.rb', line 32

def output
  raise BrewOutdatedFormatter::UnknownFormatError, options[:format] unless allow_format?
  return if STDIN.tty?

  formatter = create_formatter
  formatter.read_stdin
  puts formatter.convert
end

#versionObject



44
45
46
# File 'lib/brew_outdated_formatter/cli.rb', line 44

def version
  puts "brew_outdated_formatter #{BrewOutdatedFormatter::VERSION}"
end