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
-
.prepended(base) ⇒ Object
Hook called when this module is prepended to a class.
Instance Method Summary collapse
-
#call(**options) ⇒ Object
Store the –yes flag for use in confirm?.
Class Method Details
.prepended(base) ⇒ Object
Hook called when this module is prepended to a class
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?
25 26 27 28 |
# File 'lib/factorix/cli/commands/confirmable.rb', line 25 def call(**) @yes = [:yes] super end |