Class: OKF::CLI::Tags
Overview
The tag index: which tags exist, how often, and on what. --by regroups them per concept dimension, which is the view for curating a vocabulary rather than reading one.
Constant Summary
Constants inherited from Command
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Command
Constructor Details
This class inherits a constructor from OKF::CLI::Command
Class Method Details
.group ⇒ Object
13 14 15 |
# File 'lib/okf/cli/tags.rb', line 13 def self.group :read end |
.help_rows ⇒ Object
17 18 19 20 21 |
# File 'lib/okf/cli/tags.rb', line 17 def self.help_rows [ [ "tags <dir|@slug> [--json] [--by DIM] [filters]", "list tags with their concepts, by count" ] ] end |
.id ⇒ Object
9 10 11 |
# File 'lib/okf/cli/tags.rb', line 9 def self.id :tags end |
Instance Method Details
#call(argv) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/okf/cli/tags.rb', line 23 def call(argv) = { json: false, by: nil } parser = OptionParser.new do |o| o. = "Usage: okf tags <dir|@slug> [--by type|area] [--type T] [--area A] [--json]" json_flags(o, , "emit the tag index as JSON") o.on("--by DIM", %w[type area], "group the tags by a concept dimension (type | area)") { |v| [:by] = v.to_sym } filter_flags(o, , :type, :area) help_flag(o) end dir = positional_dir(parser, argv) or return 2 return (dir, ) if [:by] print_inverted_index(dir, "Tags", :tag, "tags", ) end |