Class: Wikiwiki::CLI::Commands::Page::Show

Inherits:
Base
  • Object
show all
Defined in:
lib/wikiwiki/cli/commands/page/show.rb

Overview

Show page metadata

Instance Method Summary collapse

Instance Method Details

#call(page_name:, out: $stdout, err: $stderr, **options) ⇒ void

This method returns an undefined value.

Execute the show command

Parameters:

  • page_name (String)

    name of the page to show

  • options (Hash)

    command options including wiki_id, auth, json, verbose, out, err



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/wikiwiki/cli/commands/page/show.rb', line 19

def call(page_name:, out: $stdout, err: $stderr, **options)
  wiki = create_wiki(out:, err:, **options)
  page = wiki.page(page_name:)

   = {
    "name" => page.name,
    "timestamp" => page.timestamp.iso8601,
    "source_size" => page.source.bytesize
  }

  if options[:json]
    out.puts Formatter::JSON.new.format()
  else
    out.puts "Name: #{metadata["name"]}"
    out.puts "Timestamp: #{metadata["timestamp"]}"
    out.puts "Source size: #{metadata["source_size"]} bytes"
    say("Page metadata retrieved", out:, **options)
  end
end