module Obsctl::CLI::Completions

Overview

Generates shell completion scripts from the command registry.

Nothing here hardcodes a command name: the word lists come from Domain::CommandRegistry, so a command added there completes everywhere without a second edit. Argument values that only the daemon knows — scene, profile, collection, and audio-input names — are completed by shelling back out to obsctl, which keeps the suggestions live.

Extended Modules

Defined in:

obsctl/cli/completions.cr

Constant Summary

CANDIDATE_KINDS = ["scenes", "profiles", "collections", "audio"]

Kinds of live name obsctl completions candidates can list.

GLOBAL_FLAGS = ["--config", "--log-level", "--color", "--timeout", "--force", "--json", "--quiet", "--version", "--help"]
LOCAL_COMMANDS = ["init", "doctor", "config", "watch", "completions", "server", "service", "tui", "version", "help"]
LOCAL_SUBCOMMANDS = {"config" => ["explain", "diff", "migrate"], "service" => ["install", "uninstall", "start", "stop", "restart", "status"]}

Subcommands the CLI serves locally, with their own fixed arguments.

SHELLS = ["bash", "zsh", "fish"]

Instance Method Summary

Instance Method Detail

def candidates(kind : String, snapshot : JSON::Any | Nil) : Array(String) #

Lists live names for one kind, one per line.

Completion runs on every Tab press, so an unreachable daemon or a malformed reply yields no candidates instead of an error: a shell completion that prints a diagnostic into the command line is worse than one that suggests nothing.


[View source]
def commands : Array(String) #

Every word that can appear in the command position.


[View source]
def dynamic_argument_commands : Hash(String, Array(String)) #

Commands whose first argument names a live OBS resource, grouped by the obsctl query that lists those names.


[View source]
def render(shell : String) : String #

Renders the completion script for one shell.


[View source]
def static_argument_commands : Hash(String, Array(String)) #

Commands whose first argument is a fixed word list.


[View source]