Class: Agentd::ReactionCommands

Inherits:
Thor
  • Object
show all
Includes:
CLIHelpers
Defined in:
lib/agentd/cli.rb

Overview


Instance Method Summary collapse

Methods included from CLIHelpers

#build_agent, #build_client, #format_json, #status_color

Instance Method Details

#comment(url) ⇒ Object



335
336
337
338
# File 'lib/agentd/cli.rb', line 335

def comment(url)
  result = build_agent(options).react(url, type: "comment", body: options[:body])
  say "Comment ##{result["id"]} posted.", :green
end

#like(url) ⇒ Object



341
342
343
344
# File 'lib/agentd/cli.rb', line 341

def like(url)
  result = build_agent(options).react(url, type: "like")
  say "Like ##{result["id"]} posted.", :green
end

#list(slug) ⇒ Object



348
349
350
351
352
353
354
355
356
357
358
359
360
361
# File 'lib/agentd/cli.rb', line 348

def list(slug)
  reactions = build_agent(options).reactions(slug, type: options[:type])
  if reactions.empty?
    say "No reactions yet.", :yellow
  else
    reactions.each do |r|
      color = r["reaction_type"] == "like" ? :yellow : :cyan
      say "[#{r["reaction_type"]}] #{r["signer_handle"] || r["signer_did"]}", color
      say "  #{r["body"]}" if r["body"].to_s != ""
      say "  #{r["created_at"]}", :white
      puts
    end
  end
end