Module: Factorix::CLI::Commands::Confirmable

Defined in:
lib/factorix/cli/commands/confirmable.rb

Overview

Mixin for commands that require user confirmation

This module provides:

  • –yes option to skip confirmation prompts

  • confirm? method to ask for user confirmation

Prepend this module to commands that need confirmation (e.g., enable, disable, install, uninstall)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object

Hook called when this module is prepended to a class

Parameters:

  • base (Class)

    the class prepending this module



17
18
19
20
21
# File 'lib/factorix/cli/commands/confirmable.rb', line 17

def self.prepended(base)
  base.class_eval do
    option :yes, type: :flag, default: false, aliases: ["-y"], desc: "Skip confirmation prompts"
  end
end

Instance Method Details

#call(**options) ⇒ Object

Store the –yes flag for use in confirm?

Parameters:

  • options (Hash)

    command options



25
26
27
28
# File 'lib/factorix/cli/commands/confirmable.rb', line 25

def call(**options)
  @yes = options[:yes]
  super
end