Sha256: 716771b157bba50b54b3d355a9b3259bc399ba1a1f01699819dc7bfedfb9b821
Contents?: true
Size: 1.07 KB
Versions: 10
Compression:
Stored size: 1.07 KB
Contents
class UltraCommandLine::Manager::Base class << self def add_provider_for(command_or_option, provider) providers = providers_for command_or_option providers << provider unless providers.include? provider end def providers_for(command_or_option) default_command_data = {options: {}, providers: []} case command_or_option when UltraCommandLine::Commands::SubCommand sc = command_or_option internal_provider_mapping[sc.name] ||= default_command_data internal_provider_mapping[sc.name][:providers] when UltraCommandLine::Commands::OptionDefinition sco = command_or_option internal_provider_mapping[sco.sub_command.name] ||= default_command_data internal_provider_mapping[sco.sub_command.name][:options][sco.name] ||= [] internal_provider_mapping[sco.sub_command.name][:options][sco.name] else raise PowerStencil::Error, "Invalid command or option" end end # private def internal_provider_mapping @internal_provider_mapping ||= {} end end end
Version data entries
10 entries across 10 versions & 1 rubygems