Class: Factorix::CLI::Commands::Cache::Stat

Inherits:
Base
  • Object
show all
Includes:
Formatting
Defined in:
lib/factorix/cli/commands/cache/stat.rb

Overview

Display cache statistics

This command outputs statistics for all cache stores in a human-readable or JSON format.

Examples:

$ factorix cache stat
download:
  TTL:            unlimited
  Entries:        42 / 42 (100.0% valid)
  ...

Instance Method Summary collapse

Methods included from Formatting

#format_duration, #format_size

Methods inherited from Base

backup_support!, confirmable!, inherited, require_game_stopped!

Instance Method Details

#call(json:) ⇒ void

This method returns an undefined value.

Execute the cache stat command

Parameters:

  • json (Boolean)

    output in JSON format



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/factorix/cli/commands/cache/stat.rb', line 41

def call(json:, **)
  logger.debug("Collecting cache statistics")

  cache_names = Factorix.config.cache.values.keys
  stats = cache_names.to_h {|name| [name, collect_stats(name)] }

  if json
    out.puts JSON.pretty_generate(stats)
  else
    output_text(stats)
  end
end