Class: Wikiwiki::CLI::Commands::Auth

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

Overview

Authenticate and output JWT token

Instance Method Summary collapse

Instance Method Details

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

This method returns an undefined value.

Execute the auth command

Parameters:

  • options (Hash)

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



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/wikiwiki/cli/commands/auth.rb', line 16

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

  if options[:json]
    out.puts Formatter::JSON.new.format({"token" => token})
  else
    out.puts token
    say("Authentication successful", out:, **options)
  end
end