Module: Factorix::CLI::Commands::Confirmable
- Included in:
- MOD::Disable, MOD::Enable, MOD::Uninstall
- Defined in:
- lib/factorix/cli/commands/confirmable.rb,
sig/factorix/cli/commands/confirmable.rbs
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 |