Class: OKF::CLI::Dirs
Overview
The bundle's directories — its clusters — and how many concepts live
directly in each. The shape view: index reads a directory's contents,
dirs reads the layout they hang off, which is the question --dir is
answered against.
count is direct, never cumulative: a dir's number is what lives in it,
so the column sums to the bundle's concept count and an empty intermediate
dir reads as the zero it is. subtree is the other half of that honesty —
what --dir <that row> would return — because a direct count alone cannot
say where the mass is once --depth truncates the listing: on a deep
bundle the top-level rows are then all zeroes.
Presentation only — every number comes off Bundle#directory_index, the same
source okf index and the server's Index panel read. Advisory: exit 0.
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
24 25 26 |
# File 'lib/okf/cli/dirs.rb', line 24 def self.group :read end |
.help_rows ⇒ Object
28 29 30 31 32 |
# File 'lib/okf/cli/dirs.rb', line 28 def self.help_rows [ [ "dirs <dir|@slug> [--json] [--dir D] [--depth N]", "list the bundle's dirs (clusters) and their concept counts" ] ] end |
.id ⇒ Object
20 21 22 |
# File 'lib/okf/cli/dirs.rb', line 20 def self.id :dirs end |
Instance Method Details
#call(argv) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/okf/cli/dirs.rb', line 34 def call(argv) = { json: false, dirs: nil, depth: nil, ancestors: true } parser = OptionParser.new do |o| o. = "Usage: okf dirs <dir|@slug> [--dir PATH] [--depth N] [--json]" json_flags(o, , "emit the dirs as JSON") projection_flags(o, ) o.on("--dir PATH", "only this directory and the ones below it", "(repeatable; `root` for the bundle root)") { |v| ([:dirs] ||= []) << v } depth_flag(o, ) ancestors_flag(o, ) help_flag(o) end dir = positional_dir(parser, argv) or return 2 bad_depth = depth_error() return bad_depth if bad_depth folder = OKF::Bundle::Folder.load(dir) report_skipped(folder) rows = select_rows(folder.directory_index, ) return emit_list_json(dir, "dirs", rows, , "total" => total(rows)) if [:json] print_dirs(dir, rows) 0 end |