class ForemanMaintain::Cli::Base

Public Class Methods

interactive_option() click to toggle source
# File lib/foreman_maintain/cli/base.rb, line 60
def self.interactive_option
  option ['-y', '--assumeyes'], :flag,
         'Automatically answer yes for all questions'
end
label_option() click to toggle source
# File lib/foreman_maintain/cli/base.rb, line 42
def self.label_option
  option '--label', 'label',
         'Limit only for a specific label. '                   '(Use "list" command to see available labels)' do |label|
    raise ArgumentError, 'value not specified' if label.nil? || label.empty?
    underscorize(label).to_sym
  end
end
tags_option() click to toggle source
# File lib/foreman_maintain/cli/base.rb, line 51
def self.tags_option
  option '--tags', 'tags',
         'Limit only for specific set of labels. '                   '(Use list-tags command to see available tags)' do |tags|
    raise ArgumentError, 'value not specified' if tags.nil? || tags.empty?
    tags.split(',').map(&:strip).map { |tag| underscorize(tag).to_sym }
  end
end

Public Instance Methods

available_checks() click to toggle source
# File lib/foreman_maintain/cli/base.rb, line 32
def available_checks
  filter = {}
  filter[:tags] = tags if respond_to?(:tags)
  ForemanMaintain.available_checks(filter)
end
available_tags(collection) click to toggle source
# File lib/foreman_maintain/cli/base.rb, line 38
def available_tags(collection)
  collection.inject([]) { |array, check| array.concat(check.tags).uniq }.sort_by(&:to_s)
end
dashize(string) click to toggle source
# File lib/foreman_maintain/cli/base.rb, line 6
def dashize(string)
  string.to_s.tr('_', '-')
end
label_string(string) click to toggle source
# File lib/foreman_maintain/cli/base.rb, line 14
def label_string(string)
  HighLine.color("[#{dashize(string)}]", :yellow)
end
reporter() click to toggle source
# File lib/foreman_maintain/cli/base.rb, line 22
def reporter
  @reporter ||= ForemanMaintain::Reporter::CLIReporter.new(STDOUT,
                                                           STDIN,
                                                           :assumeyes => assumeyes?)
end
run_scenario(scenario) click to toggle source
# File lib/foreman_maintain/cli/base.rb, line 28
def run_scenario(scenario)
  ForemanMaintain::Runner.new(reporter, scenario, :assumeyes => assumeyes?).run
end
tag_string(string) click to toggle source
# File lib/foreman_maintain/cli/base.rb, line 18
def tag_string(string)
  HighLine.color("[#{dashize(string)}]", :cyan)
end
underscorize(string) click to toggle source
# File lib/foreman_maintain/cli/base.rb, line 10
def underscorize(string)
  string.to_s.tr('-', '_')
end