Sha256: 69df546e27783be70adf811f7ccf77829ec1f4a43f159f52d1d7b2e26c3c6abf
Contents?: true
Size: 1.4 KB
Versions: 4
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true require 'optparse' require_relative 'cli/parsers' require_relative 'cli/parser_options' require_relative 'cli/try_unlock_subscriptions_set' require_relative 'cli/exit_codes' require_relative 'cli/commands' module PgEventstore module CLI OPTIONS_PARSER = { "subscriptions" => [Parsers::SubscriptionParser, ParserOptions::SubscriptionOptions].freeze }.tap do |directions| directions.default = [Parsers::DefaultParser, ParserOptions::DefaultOptions].freeze end.freeze COMMANDS = { ["subscriptions", "start"].freeze => Commands::StartSubscriptionsCommand, ["subscriptions", "stop"].freeze => Commands::StopSubscriptionsCommand }.freeze class << self # @return [PgEventstore::Callbacks] def callbacks @callbacks ||= Callbacks.new end # @param args [Array<String>] # @return [Integer] exit code def execute(args) options_parser_class, options_class = OPTIONS_PARSER[args[0]] command, parsed_options = options_parser_class.new(ARGV, options_class.new).parse return Commands::HelpCommand.new(parsed_options).call if parsed_options.help return COMMANDS[command].new(parsed_options).call if COMMANDS[command] _, parsed_options = options_parser_class.new(['-h'], options_class.new).parse Commands::HelpCommand.new(parsed_options).call end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
pg_eventstore-1.9.0 | lib/pg_eventstore/cli.rb |
pg_eventstore-1.8.0 | lib/pg_eventstore/cli.rb |
pg_eventstore-1.7.0 | lib/pg_eventstore/cli.rb |
pg_eventstore-1.6.0 | lib/pg_eventstore/cli.rb |