lib/codeowner_validator/helpers/config_helper.rb
# Public: An abstraction onto the TTY:Prompt.ask to allow requesting information from the user's input
# and saving that input within the base module's configuration
#
# @param [Hash] args The arguments in which to accept
# @option args [String] :ident The identifier to the config to store
# @option args [String] :prompt The prompt to display to the user
# @option args [String] :default The default value to display
# @option args [Boolean] :required Indicates if the requested ask required input from the user
# @option args [Boolean] :force_ask Indicates to ignore previous ask and perform again
# @option args [Boolean] :mask Indicates that the response should be hidden
An abstraction onto the TTY:Prompt.ask to allow requesting information from the user's input
and saving that input within the base module's configuration
An abstraction onto the TTY : Prompt . ask to allow requesting information from the user ' s input and saving that input within the base module ' s configuration
def ask(ident:, prompt:, required: false, force_ask: false, mask: false, **args)
        opts =
          {}.tap do |h|
            h[:required] = required
            h[:default] = args[:default] if args[:default]
          end
        return if !force_ask && ::CodeownerValidator.respond_to?(ident)
        tty_prompt = ::TTY::Prompt.new
        response =
          tty_prompt.collect do
            if mask
              key(ident.to_sym).mask(
                prompt,
                opts
              )
            else
              key(ident.to_sym).ask(
                prompt,
                opts
              )
            end
          end
        ::CodeownerValidator.configure! response
      end
def ask ( ident : , prompt : , required : false , force_ask : false , mask : false , ** args ) opts = { } . tap do | h | h [ :required ] = required h [ :default ] = args [ :default ] if args [ :default ] end return if ! force_ask && :: CodeownerValidator . respond_to? ( ident ) tty_prompt = :: TTY :: Prompt . new response = tty_prompt . collect do if mask key ( ident . to_sym ) . mask ( prompt , opts ) else key ( ident . to_sym ) . ask ( prompt , opts ) end end :: CodeownerValidator . configure! response end
Public: An abstraction onto the TTY:Prompt.ask to allow requesting information from the user's input
and saving that input within the base module's configuration
Public : An abstraction onto the TTY : Prompt . ask to allow requesting information from the user ' s input and saving that input within the base module ' s configuration
# return if either not being forced to ask or the information has been previously captured
ident
prompt
required
force_ask
mask
args
:mask Indicates that the response should be hidden
: mask Indicates that the response should be hidden
args The arguments in which to accept
args The arguments in which to accept