Class: BundleOutdatedFormatter::CLI

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

Overview

Command-line interface of BundleOutdatedFormatter

Constant Summary collapse

FORMATTERS =
{
  'terminal' => TerminalFormatter,
  'markdown' => MarkdownFormatter,
  'json'     => JSONFormatter,
  'yaml'     => YAMLFormatter,
  'csv'      => CSVFormatter,
  'tsv'      => TSVFormatter,
  'xml'      => XMLFormatter,
  'html'     => HTMLFormatter
}.freeze
STYLES =
%w[unicode ascii].freeze

Instance Method Summary collapse

Instance Method Details

#outputObject



34
35
36
37
38
39
40
41
42
# File 'lib/bundle_outdated_formatter/cli.rb', line 34

def output
  raise BundleOutdatedFormatter::UnknownFormatError, options[:format] unless allow_format?
  raise BundleOutdatedFormatter::UnknownStyleError, options[:style] unless allow_style?
  return if STDIN.tty?

  formatter = create_formatter
  formatter.read_stdin
  puts formatter.convert
end

#versionObject



47
48
49
# File 'lib/bundle_outdated_formatter/cli.rb', line 47

def version
  puts "bundle_outdated_formatter #{BundleOutdatedFormatter::VERSION}"
end