Class: Slk::Commands::Messages
- Includes:
- Support::InlineImages
- Defined in:
- lib/slk/commands/messages.rb
Overview
Reads messages from channels, DMs, or threads rubocop:disable Metrics/ClassLength
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
#options, #positional_args, #runner
Instance Method Summary collapse
-
#execute ⇒ Object
rubocop:disable Metrics/MethodLength.
- #fetch_and_display_messages(resolved) ⇒ Object
-
#missing_target_error ⇒ Object
rubocop:enable Metrics/MethodLength.
- #output_messages(messages, workspace, channel_id) ⇒ Object
Methods included from Support::InlineImages
#convert_to_png, #in_tmux?, #inline_images_supported?, #iterm2_protocol_supported?, #kitty_graphics_supported?, #png_data?, #print_inline_image, #print_inline_image_with_text, #print_iterm_image, #print_kitty_image, #print_tmux_iterm_image, #print_tmux_kitty_image, #read_image_data_for_protocol, #tmux_client_is_kitty_compatible?
Methods inherited from Base
Constructor Details
This class inherits a constructor from Slk::Commands::Base
Instance Method Details
#execute ⇒ Object
rubocop:disable Metrics/MethodLength
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/slk/commands/messages.rb', line 14 def execute result = return result if result target = positional_args.first return missing_target_error unless target resolved = target_resolver.resolve(target, default_workspace: target_workspaces.first) (resolved) rescue ApiError => e error("Failed to fetch messages: #{e.}") 1 rescue ArgumentError => e error(e.) 1 end |
#fetch_and_display_messages(resolved) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/slk/commands/messages.rb', line 37 def (resolved) apply_default_limit(resolved.msg_ts) = (resolved.workspace, resolved.channel_id, resolved.thread_ts, oldest: resolved.msg_ts) = enrich_reactions(, resolved.workspace, resolved.channel_id) if @options[:reaction_timestamps] (, resolved.workspace, resolved.channel_id) 0 end |
#missing_target_error ⇒ Object
rubocop:enable Metrics/MethodLength
32 33 34 35 |
# File 'lib/slk/commands/messages.rb', line 32 def missing_target_error error('Usage: slk messages <channel|@user|url>') 1 end |
#output_messages(messages, workspace, channel_id) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/slk/commands/messages.rb', line 46 def (, workspace, channel_id) if @options[:json] (, workspace, channel_id) else (, workspace, channel_id) end end |