Class: Wikiwiki::CLI::Commands::Attachment::List

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

Overview

List attachments on a page

Instance Method Summary collapse

Instance Method Details

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

This method returns an undefined value.

Execute the list command

Parameters:

  • page_name (String)

    name of the page

  • options (Hash)

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



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/wikiwiki/cli/commands/attachment/list.rb', line 20

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

  if options[:json]
    out.puts Formatter::JSON.new.format(attachment_names)
  else
    attachment_names.each {|name| out.puts name }
    say("#{attachment_names.size} attachments found", out:, **options)
  end
end