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.



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/abide_dev_utils/cli/jira.rb', line 160

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('-z', '--print-only', 'Prints a list of issues that would be created. Implies dry-run, and auto-approve, but less verbose than --dry-run.') do
    @data[:print_only] = true
    @data[:dry_run] = true
    @data[:auto_approve] = true
  end
  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



187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/abide_dev_utils/cli/jira.rb', line 187

def execute(path1, path2, project)
  Abide::CLI::VALIDATE.file(path1)
  Abide::CLI::VALIDATE.file(path2)
  AbideDevUtils::Jira.new_issues_from_xccdf_diff(
    project,
    path1,
    path2,
    epic: @data[:epic],
    dry_run: @data[:dry_run],
    print_only: @data[:print_only],
    auto_approve: @data[:auto_approve],
    diff_opts: @data[:diff_opts] || {},
  )
end