Module: JCF::CLI
- Extended by:
- Dry::CLI::Registry
- Defined in:
- lib/jcf/cli.rb,
lib/jcf/cli/errors.rb,
lib/jcf/cli/command.rb,
lib/jcf/cli/commands.rb,
lib/jcf/cli/commands/plugins.rb,
lib/jcf/cli/commands/version.rb,
lib/jcf/cli/commands/cf/quota.rb,
lib/jcf/cli/commands/cf/users.rb,
lib/jcf/cli/output_formatters.rb,
lib/jcf/cli/commands/cf/spaces.rb,
lib/jcf/cli/commands/cf/metrics.rb,
lib/jcf/cli/commands/cf/services.rb,
lib/jcf/cli/output_formatters/csv.rb,
lib/jcf/cli/output_formatters/json.rb,
lib/jcf/cli/output_formatters/text.rb,
lib/jcf/cli/commands/cf/organizations.rb,
lib/jcf/cli/commands/cf/service_plans.rb,
lib/jcf/cli/commands/cf/service_brokers.rb,
lib/jcf/cli/commands/cf/service_instances.rb,
lib/jcf/cli/commands/cf/service_offerings.rb
Defined Under Namespace
Modules: Commands, OutputFormatters Classes: Command, EmptyResultError, Error, InvalidOptionError, NotImplementedError, NotLoggedInError
Class Method Summary collapse
-
.loader ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
-
.register_commands! ⇒ Object
rubocop:disable Metrics/MethodLength.
- .register_formatters! ⇒ Object
-
.template_parser(template, values) ⇒ Object
template parsing: “guid-name”, “guid=1234,name=test” TODO: add some form of validation and error handling.
Class Method Details
.loader ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/jcf/cli.rb', line 64 def self.loader @loader ||= Zeitwerk::Loader.new.tap do |loader| loader.inflector = Zeitwerk::GemInflector.new("#{JCF.root}/jcf.rb") loader.push_dir(JCF.root) loader.ignore( "#{JCF.root}/jcf/cli/{errors,version}.rb" ) loader.inflector.inflect("jcf" => "JCF") loader.inflector.inflect("cf" => "CF") loader.inflector.inflect("cli" => "CLI") loader.inflector.inflect("url" => "URL") loader.inflector.inflect("json" => "JSON") loader.inflector.inflect("csv" => "CSV") loader.inflector.inflect("aws" => "AWS") end end |
.register_commands! ⇒ Object
rubocop:disable Metrics/MethodLength
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/jcf/cli/commands.rb', line 9 def self.register_commands! register "version", Commands::Version, aliases: ["v", "-v", "--version"] register "plugins", Commands::Plugins register "metrics", Commands::CF::Metrics, aliases: ["m"] register "organizations", Commands::CF::Organizations, aliases: %w[o orgs organization] register "spaces", Commands::CF::Spaces, aliases: %w[s space] register "users", Commands::CF::Users, aliases: %w[u user] register "services", Commands::CF::Services register "service_brokers", Commands::CF::ServiceBrokers, aliases: %w[sb service_broker] register "service_offerings", Commands::CF::ServiceOfferings, aliases: %w[so service_offering] register "service_instances", Commands::CF::ServiceInstances, aliases: %w[si service_instance] register "service_plans", Commands::CF::ServicePlans, aliases: %w[sp service_plan] end |
.register_formatters! ⇒ Object
19 20 21 22 23 24 |
# File 'lib/jcf/cli/output_formatters.rb', line 19 def self.register_formatters! Dir[File.join(__dir__, "output_formatters", "*.rb")].each { |f| require f } OutputFormatters.constants.each do |c| OutputFormatters.register_formatter(c.to_s.downcase, OutputFormatters.const_get(c)) end end |
.template_parser(template, values) ⇒ Object
template parsing: “guid-name”, “guid=1234,name=test” TODO: add some form of validation and error handling
84 85 86 87 88 89 90 91 92 |
# File 'lib/jcf/cli.rb', line 84 def self.template_parser(template, values) result = template.dup (values || "").split(",").each do |value| key, val = value.split("=") result.gsub!("{#{key}}", val) end result end |