Feature: CLI Command Bus Decoupling
  As a developer
  I want the CLI layer to be decoupled from application services
  So that the architecture maintains proper separation of concerns

  Background:
    Given the command bus is initialized
    And no handlers are registered

  Scenario: Command bus can be created
    When I create a new command bus
    Then the command bus should be empty
    And no handlers should be registered

  Scenario: Handler registration
    Given a command bus
    When I register a handler for a command type
    Then the handler should be registered
    And the command bus should have the handler

  Scenario: Command dispatch to registered handler
    Given a command bus with a registered handler
    When I dispatch a command
    Then the handler should be invoked
    And the result should be returned

  Scenario: Dispatch fails for unregistered command
    Given a command bus with no handlers
    When I dispatch a command without a registered handler
    Then a ValueError should be raised for unregistered command dispatch
    And the error message should mention the command type

  Scenario: Handler check
    Given a command bus
    When I check if a handler exists for a command type
    Then the result should be accurate
    And reflect the registration status

  Scenario: Global command bus instance
    When I get the global command bus
    Then I should receive a CommandBus instance
    And subsequent calls should return the same instance

  Scenario: Set global command bus
    Given a new command bus
    When I set it as the global command bus
    Then subsequent calls to get_command_bus should return it
    And the previous instance should be replaced
