Module: Clack::Core::CiMode

Defined in:
lib/clack/core/ci_mode.rb

Overview

Non-interactive mode for CI environments and piped input.

When enabled, prompts auto-submit with their default values instead of waiting for user input. Useful for CI pipelines, automated testing, and scripted usage where stdin isn't a TTY.

Enable explicitly:

Clack.update_settings(ci_mode: true)

Or auto-detect (non-TTY input or CI environment variable):

Clack.update_settings(ci_mode: :auto)

Class Method Summary collapse

Class Method Details

.active?(input = $stdin) ⇒ Boolean

Check if CI mode is currently active.

Parameters:

  • input (IO, nil) (defaults to: $stdin)

    the prompt's input stream, consulted by :auto (default: $stdin; nil also means $stdin, matching KeyReader's console fallback)

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
32
33
34
# File 'lib/clack/core/ci_mode.rb', line 24

def active?(input = $stdin)
  setting = Settings.config[:ci_mode]
  case setting
  when true
    true
  when :auto
    !Environment.tty?(input || $stdin) || Environment.ci?
  else
    false
  end
end