Class: Factorix::CLI::Commands::Completion

Inherits:
Base
  • Object
show all
Defined in:
lib/factorix/cli/commands/completion.rb

Overview

Generate shell completion script for factorix

This command outputs a shell completion script that can be evaluated to enable command-line completion for factorix.

Examples:

Enable completion (auto-detect shell)

eval "$(factorix completion)"

Enable completion for specific shell

eval "$(factorix completion zsh)"

Instance Method Summary collapse

Methods inherited from Base

backup_support!, confirmable!, inherited, require_game_stopped!

Instance Method Details

#call(shell: nil) ⇒ void

This method returns an undefined value.

Execute the completion command

Parameters:

  • shell (String, nil) (defaults to: nil)

    Shell type (zsh, bash, fish)

Raises:



48
49
50
51
52
53
54
55
56
# File 'lib/factorix/cli/commands/completion.rb', line 48

def call(shell: nil, **)
  shell_type = shell || detect_shell
  validate_shell!(shell_type)

  script_path = COMPLETION_DIR / SUPPORTED_SHELLS[shell_type]
  raise ConfigurationError, "#{shell_type.capitalize} completion script not found" unless script_path.exist?

  out.puts script_path.read
end