Module: PgEventstore::CLI

Defined in:
lib/pg_eventstore/cli.rb,
lib/pg_eventstore/cli/exit_codes.rb,
lib/pg_eventstore/cli/parsers/base_parser.rb,
lib/pg_eventstore/cli/commands/base_command.rb,
lib/pg_eventstore/cli/commands/help_command.rb,
lib/pg_eventstore/cli/parsers/default_parser.rb,
lib/pg_eventstore/cli/parser_options/metadata.rb,
lib/pg_eventstore/cli/parser_options/base_options.rb,
lib/pg_eventstore/cli/parsers/subscription_parser.rb,
lib/pg_eventstore/cli/try_unlock_subscriptions_set.rb,
lib/pg_eventstore/cli/parser_options/default_options.rb,
lib/pg_eventstore/cli/try_to_delete_subscriptions_set.rb,
lib/pg_eventstore/cli/commands/stop_subscriptions_command.rb,
lib/pg_eventstore/cli/parser_options/subscription_options.rb,
lib/pg_eventstore/cli/wait_for_subscriptions_set_shutdown.rb,
lib/pg_eventstore/cli/commands/start_subscriptions_command.rb,
lib/pg_eventstore/cli/commands/callback_handlers/start_cmd_handlers.rb

Defined Under Namespace

Modules: Commands, ExitCodes, ParserOptions, Parsers Classes: TryToDeleteSubscriptionsSet, TryUnlockSubscriptionsSet, WaitForSubscriptionsSetShutdown

Constant Summary collapse

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 Method Summary collapse

Class Method Details

.callbacksPgEventstore::Callbacks



25
26
27
# File 'lib/pg_eventstore/cli.rb', line 25

def callbacks
  @callbacks ||= Callbacks.new
end

.execute(args) ⇒ Integer

Returns exit code.

Parameters:

  • args (Array<String>)

Returns:

  • (Integer)

    exit code



31
32
33
34
35
36
37
38
39
# File 'lib/pg_eventstore/cli.rb', line 31

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