Class: OKF::CLI::Types

Inherits:
Command show all
Defined in:
lib/okf/cli/types.rb

Overview

The type index: which types exist, how often, and on what.

Constant Summary

Constants inherited from Command

Command::DUCK_TYPE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

hidden?, #initialize

Constructor Details

This class inherits a constructor from OKF::CLI::Command

Class Method Details

.groupObject



11
12
13
# File 'lib/okf/cli/types.rb', line 11

def self.group
  :read
end

.help_rowsObject



15
16
17
18
19
# File 'lib/okf/cli/types.rb', line 15

def self.help_rows
  [
    [ "types     <dir|@slug> [--json] [filters]", "list types with their concepts, by count" ]
  ]
end

.idObject



7
8
9
# File 'lib/okf/cli/types.rb', line 7

def self.id
  :types
end

Instance Method Details

#call(argv) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/okf/cli/types.rb', line 21

def call(argv)
  options = { json: false }
  parser = OptionParser.new do |o|
    o.banner = "Usage: okf types <dir|@slug> [--area A] [--tag T] [--json]"
    json_flags(o, options, "emit the type index as JSON")
    filter_flags(o, options, :area, :tag)
    help_flag(o)
  end
  dir = positional_dir(parser, argv) or return 2

  print_inverted_index(dir, "Types", :type, "types", options)
end