Class: HammerCLIKatello::ContentViewPurgeCommand

Inherits:
Command
  • Object
show all
Includes:
HammerCLIForemanTasks::Async, ApipieHelper, OrganizationOptions
Defined in:
lib/hammer_cli_katello/content_view_purge.rb

Defined Under Namespace

Classes: ContentViewIdParamSource

Instance Method Summary collapse

Methods included from OrganizationOptions

included, #org_options

Methods included from ApipieHelper

#call, #destroy, #index, #show, #update

Methods included from ResolverCommons

included

Instance Method Details

#executeObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/hammer_cli_katello/content_view_purge.rb', line 51

def execute
  if option_count.negative?
    output.print_error _("Invalid value for --count option: value must be 0 or greater.")
    return HammerCLI::EX_USAGE
  end

  # Check if there is something to do
  if option_count >= old_unused_versions.size
    output.print_error _("No versions to delete.")
    HammerCLI::EX_NOT_FOUND
  else
    versions_to_purge = old_unused_versions.slice(0, old_unused_versions.size - option_count)

    versions_to_purge.each do |v|
      purge_version(v)
    end
    HammerCLI::EX_OK
  end
end

#option_sourcesObject



41
42
43
44
45
46
47
48
49
# File 'lib/hammer_cli_katello/content_view_purge.rb', line 41

def option_sources
  sources = super
  sources.find_by_name('IdResolution').insert_relative(
    :after,
    'IdParams',
    ContentViewIdParamSource.new(self)
  )
  sources
end