Class: Rubyists::Linear::CLI::Issue::List

Inherits:
Object
  • Object
show all
Includes:
CommonOptions, SemanticLogger::Loggable
Defined in:
lib/linear/commands/issue/list.rb

Overview

The List class is a Dry::CLI::Command that lists issues

Instance Method Summary collapse

Methods included from CommonOptions

#display, included

Instance Method Details

#call(ids:, **options) ⇒ Object



33
34
35
36
37
38
# File 'lib/linear/commands/issue/list.rb', line 33

def call(ids:, **options)
  logger.debug 'Listing issues'
  return display(issues_for(options), options) if ids.empty?

  display issues_for(options.merge(ids:)), options
end

#filters_for(options) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/linear/commands/issue/list.rb', line 40

def filters_for(options)
  filter = {}
  filter[:assignee] = { isMe: { eq: true } } if options[:mine]
  filter[:assignee] = { null: true } if options[:unassigned]
  filter[:team] = { key: { eq: options[:team] } } if options[:team]
  filter
end

#issues_for(options) ⇒ Object



48
49
50
51
52
53
# File 'lib/linear/commands/issue/list.rb', line 48

def issues_for(options)
  logger.debug('Fetching issues', options:)
  return options[:ids].map { |id| Rubyists::Linear::Issue.find(id.upcase) } if options[:ids]

  Rubyists::Linear::Issue.all filter: filters_for(options)
end