Project

General

Profile

« Previous | Next » 

Revision b2e88b7c

Added by Thomas McKay about 8 years ago

fixes #14162 - hide unsupported sub-commands and options

+ updated for ruby 2.0.0
+ updated README
+ fixed rubocop
+ updated tests
+ based on feedback switched to default being unsupported for new commands

View differences:

lib/hammer_cli_csv/import.rb
command_name 'import'
desc 'import by directory'
def self.supported?
true
end
option %w(-v --verbose), :flag, _('be verbose')
option %w(--threads), 'THREAD_COUNT', _('Number of threads to hammer with'),
:default => 1, :hidden => true
option '--dir', 'DIRECTORY', _('directory to import from')
option %w(--organization), 'ORGANIZATION', _('Only process organization matching this name')
option %w(--prefix), 'PREFIX', _('Prefix for all name columns')
option %w(--prefix), 'PREFIX', _('Prefix for all name columns'),
:hidden => true
RESOURCES = %w( settings organizations locations puppet_environments operating_systems
domains architectures partition_tables lifecycle_environments host_collections
provisioning_templates
subscriptions products content_views content_view_filters activation_keys
hosts content_hosts smart_proxies compute_resources reports roles users )
RESOURCES = %w(
settings organizations locations puppet_environments operating_systems
domains architectures partition_tables lifecycle_environments host_collections
provisioning_templates
subscriptions products content_views content_view_filters activation_keys
hosts content_hosts smart_proxies compute_resources reports roles users
)
SUPPORTED_RESOURCES = %w(
settings
)
RESOURCES.each do |resource|
dashed = resource.gsub('_', '-')
option "--#{dashed}", 'FILE', "csv file for #{dashed}"
option "--#{dashed}", 'FILE', "csv file for #{dashed}",
:hidden => !SUPPORTED_RESOURCES.include?(resource)
end
def execute
......
def hammer_resource(resource)
return if !self.send("option_#{resource}") && !option_dir
options_file = "#{option_dir}/#{resource.gsub('_', '-')}.csv" || self.send("option_#{resource}")
options_file = option_dir ? "#{option_dir}/#{resource.gsub('_', '-')}.csv" : self.send("option_#{resource}")
unless options_file_exists? options_file
if option_dir
return unless SUPPORTED_RESOURCES.include?(resource)
puts _("Skipping #{resource} because '#{options_file}' does not exist") if option_verbose?
return
end

Also available in: Unified diff