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

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

Overview

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

Constant Summary

Constants included from WhatFor

WhatFor::ALLOWED_PR_TYPES, WhatFor::PR_TYPES, WhatFor::PR_TYPE_SELECTIONS

Instance Method Summary collapse

Methods included from Projects

#ask_for_projects, #project_for, #project_scores

Methods included from SubCommands

#ask_for_team, #branch_for, #choose_a_team!, #current_branch, #default_branch, #git, included, #prompt, #pull_or_push_new_branch!

Methods included from WhatFor

#ask_or_edit, #cancelled_state_for, #comment_for, #completed_state_for, #description_for, #editor_for, #labels_for, #pr_description_for, #pr_scope_for, #pr_title_for, #pr_type_for, #reason_for, #team_for, #title_for

Methods included from CommonOptions

#display, included

Instance Method Details

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



38
39
40
41
42
43
# File 'lib/linear/commands/issue/list.rb', line 38

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



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/linear/commands/issue/list.rb', line 45

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]

  if options[:project]
    project = project_for(options[:project])
    logger.debug('Found project', project:)
    filter[:project] = { id: { eq: project.id } } if project
  end

  filter
end

#issues_for(options) ⇒ Object



60
61
62
63
64
65
# File 'lib/linear/commands/issue/list.rb', line 60

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