Class: Factorix::CLI::Commands::Base

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/factorix/cli/commands/base.rb

Overview

Base class for all CLI commands

This class provides common functionality for all commands:

  • Common options (–config-path, –log-level, –quiet)

  • Common helper methods (say, quiet?)

  • Pre-call setup and error handling (via CommandWrapper prepended module)

All command classes should inherit from this base class instead of directly from Dry::CLI::Command.

Examples:

Define a command

class MyCommand < Base
  desc "My command description"

  def call(**)
    say "Hello, world!"
  end
end

Class Method Summary collapse

Class Method Details

.backup_support!void

This method returns an undefined value.

Enable backup support for file modifications



68
# File 'lib/factorix/cli/commands/base.rb', line 68

def self.backup_support! = prepend BackupSupport

.confirmable!void

This method returns an undefined value.

Enable confirmation prompts with –yes option



64
# File 'lib/factorix/cli/commands/base.rb', line 64

def self.confirmable! = prepend Confirmable

.inherited(subclass) ⇒ Object

Prepend CommandWrapper to each command class that inherits from Base



53
54
55
56
# File 'lib/factorix/cli/commands/base.rb', line 53

def self.inherited(subclass)
  super
  subclass.prepend CommandWrapper
end

.require_game_stopped!void

This method returns an undefined value.

Require that the game is not running when this command executes



60
# File 'lib/factorix/cli/commands/base.rb', line 60

def self.require_game_stopped! = prepend RequiresGameStopped