Class: Abide::CLI::JiraNewIssueCommand

Inherits:
CmdParse::Command
  • Object
show all
Defined in:
lib/abide_dev_utils/cli/jira.rb

Constant Summary collapse

CMD_NAME =
'new-issue'
CMD_SHORT =
'Creates a new issue in a project'
CMD_LONG =
'Allows you to create a new issue in a project'

Instance Method Summary collapse

Constructor Details

#initializeJiraNewIssueCommand

Returns a new instance of JiraNewIssueCommand.



68
69
70
71
72
73
74
75
76
77
# File 'lib/abide_dev_utils/cli/jira.rb', line 68

def initialize
  super(CMD_NAME, takes_commands: false)
  short_desc(CMD_SHORT)
  long_desc(CMD_LONG)
  argument_desc(
    PROJECT: 'Jira project name (should be all caps)',
    SUMMARY: 'Brief summary of the issue',
    SUBTASKS: 'One or more summaries that become subtasks'
  )
end

Instance Method Details

#execute(project, summary, *subtasks) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
# File 'lib/abide_dev_utils/cli/jira.rb', line 79

def execute(project, summary, *subtasks)
  issue = AbideDevUtils::Jira.client.create(:issue, project: project, summary: summary)
  Abide::CLI::OUTPUT.simple("Successfully created #{issue.attrs['key']}")
  return if subtasks.nil? || subtasks.empty?

  Abide::CLI::OUTPUT.simple('Creatings subtasks...')
  subtasks.each do |sum|
    subtask = AbideDevUtils::Jira.client.create(:subtask, parent: issue, summary: sum)
    Abide::CLI::OUTPUT.simple("Successfully created #{subtask.attrs['key']}")
  end
end