Class: Abide::CLI::JiraFromXccdfDiffCommand

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

Constant Summary collapse

CMD_NAME =
'from-xccdf-diff'
CMD_SHORT =
'Creates an Epic with tasks from a xccdf diff'
CMD_LONG =
'Creates an Epic with tasks for changes in a diff of two XCCDF files'

Instance Method Summary collapse

Constructor Details

#initializeJiraFromXccdfDiffCommand

Returns a new instance of JiraFromXccdfDiffCommand.



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/abide_dev_utils/cli/jira.rb', line 145

def initialize
  super(CMD_NAME, takes_commands: false)
  short_desc(CMD_SHORT)
  long_desc(CMD_LONG)
  argument_desc(PATH1: 'An XCCDF file', PATH2: 'An XCCDF file', PROJECT: 'A Jira project')
  options.on('-d', '--dry-run', 'Print to console instead of saving objects') { |_| @data[:dry_run] = true }
  options.on('-y', '--yes', 'Automatically approve all yes / no prompts') { |_| @data[:auto_approve] = true }
  options.on('-e [EPIC]', '--epic [EPIC]', 'If given, tasks will be created and assigned to this epic. Takes form <PROJECT>-<NUM>') { |e| @data[:epic] = e }
  options.on('-p [PROFILE]', '--profile', 'Only diff rules belonging to the matching profile. Takes a string that is treated as RegExp') do |x|
    @data[:diff_opts] ||= {}
    @data[:diff_opts][:profile] = x
  end
  options.on('-l [LEVEL]', '--level', 'Only diff rules belonging to the matching level. Takes a string that is treated as RegExp') do |x|
    @data[:diff_opts] ||= {}
    @data[:diff_opts][:level] = x
  end
  options.on('-i [PROPS]', '--ignore-changed-properties', 'Ignore changes to specified properties. Takes a comma-separated list.') do |x|
    @data[:diff_opts] ||= {}
    @data[:diff_opts][:ignore_changed_properties] = x.split(',')
  end
end

Instance Method Details

#execute(path1, path2, project) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/abide_dev_utils/cli/jira.rb', line 167

def execute(path1, path2, project)
  Abide::CLI::VALIDATE.file(path1)
  Abide::CLI::VALIDATE.file(path2)
  @data[:dry_run] = false if @data[:dry_run].nil?
  client = JIRA.client(options: {})
  proj = JIRA.project(client, project)
  JIRA.new_issues_from_xccdf_diff(client,
                                  proj,
                                  path1,
                                  path2,
                                  epic: @data[:epic],
                                  dry_run: @data[:dry_run],
                                  auto_approve: @data[:auto_approve],
                                  diff_opts: @data[:diff_opts])
end