Class: OKF::CLI::References

Inherits:
Command
  • Object
show all
Defined in:
lib/okf/cli/references.rb

Overview

The §6.3 inventory: every file under references/, which concepts cite it through the §6.2 path-valued fields, and the pointers into references/ that resolve to nothing — with the leading-slash fix named when a bare path written from a subdirectory is what missed. An advisory read (exit 0): what a curator acts on lives in the output, never the status.

Constant Summary

Constants inherited from Command

Command::DUCK_TYPE, Command::FILTER_KEYS

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



16
17
18
# File 'lib/okf/cli/references.rb', line 16

def self.group
  :read
end

.help_rowsObject



20
21
22
23
24
# File 'lib/okf/cli/references.rb', line 20

def self.help_rows
  [
    [ "references <dir|@slug> [--json]", "inventory references/ files and the concepts citing them" ]
  ]
end

.idObject



12
13
14
# File 'lib/okf/cli/references.rb', line 12

def self.id
  :references
end

Instance Method Details

#call(argv) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/okf/cli/references.rb', line 26

def call(argv)
  options = { json: false }
  parser = OptionParser.new do |o|
    o.banner = "Usage: okf references <dir|@slug> [--json]"
    json_flags(o, options, "emit the inventory as JSON")
    projection_flags(o, options)
    help_flag(o)
  end
  dir = positional_dir(parser, argv) or return 2

  folder = OKF::Bundle::Folder.load(dir)
  report_skipped(folder)
  references = folder.references
  return print_references_json(dir, references, options) if options[:json]

  print_references(dir, references)
  0
end