Class: SimpleCovMcp::ModeDetector
- Inherits:
-
Object
- Object
- SimpleCovMcp::ModeDetector
- Defined in:
- lib/simplecov_mcp/mode_detector.rb
Overview
Centralizes the logic for detecting whether to run in CLI or MCP server mode. This makes the mode detection strategy explicit and testable.
Constant Summary collapse
- SUBCOMMANDS =
%w[list summary raw uncovered detailed totals validate version].freeze
- OPTIONS_EXPECTING_ARGUMENT =
Reference shared constant to avoid duplication with CoverageCLI
Constants::OPTIONS_EXPECTING_ARGUMENT
Class Method Summary collapse
Class Method Details
.cli_mode?(argv, stdin: $stdin) ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/simplecov_mcp/mode_detector.rb', line 14 def self.cli_mode?(argv, stdin: $stdin) # 1. Explicit flags that force CLI mode always win = %w[--force-cli -h --help --version -v] return true if argv.intersect?() # 2. Find the first non-option argument first_non_option = find_first_non_option(argv) # 3. If a non-option argument exists, it must be a CLI command (or an error) return true if first_non_option # 4. Fallback: If no non-option args, use TTY status to decide stdin.tty? end |
.mcp_server_mode?(argv, stdin: $stdin) ⇒ Boolean
30 31 32 |
# File 'lib/simplecov_mcp/mode_detector.rb', line 30 def self.mcp_server_mode?(argv, stdin: $stdin) !cli_mode?(argv, stdin: stdin) end |