module
Obsctl::Domain::CommandRegistry
Overview
The command set, and lookups over it.
Extended Modules
Defined in:
obsctl/domain/command_registry.crConstant Summary
-
BY_NAME =
begin table = {} of String => CommandSpec SPECS.each do |spec| spec.spellings.each do |spelling| table[spelling] = spec end end table end -
Every spelling mapped to its spec, including aliases.
-
RECORD_ACTIONS =
{"start" => -> do StartRecordCommand.new.as(Command) end, "stop" => -> do StopRecordCommand.new.as(Command) end, "toggle" => -> do ToggleRecordCommand.new.as(Command) end, "pause" => -> do PauseRecordCommand.new.as(Command) end, "resume" => -> do ResumeRecordCommand.new.as(Command) end, "status" => -> do RecordStatusCommand.new.as(Command) end} -
Record subcommands. Bare
reckeeps its original toggle behavior. -
SPECS =
[CommandSpec.new(name: "help", summary: "List available commands", surface: CommandSurface::Palette, build: ->(_args : Array(String)) do HelpCommand.new.as(Command) end), CommandSpec.new(name: "quit", aliases: ["exit"], summary: "Leave the dashboard", surface: CommandSurface::Palette, build: ->(_args : Array(String)) do QuitCommand.new.as(Command) end), CommandSpec.new(name: "connect", summary: "Ask the session to connect", surface: CommandSurface::Palette, build: ->(_args : Array(String)) do ConnectCommand.new.as(Command) end), CommandSpec.new(name: "disconnect", summary: "Ask the session to disconnect", surface: CommandSurface::Palette, build: ->(_args : Array(String)) do DisconnectCommand.new.as(Command) end), CommandSpec.new(name: "status", summary: "Show combined daemon and OBS status", json: true, build: ->(_args : Array(String)) do StatusCommand.new.as(Command) end), CommandSpec.new(name: "server-status", summary: "Show local daemon status only", json: true, build: ->(_args : Array(String)) do ServerStatusCommand.new.as(Command) end), CommandSpec.new(name: "obs-status", summary: "Show OBS connection and state", json: true, build: ->(_args : Array(String)) do ObsStatusCommand.new.as(Command) end), CommandSpec.new(name: "reconnect", summary: "Ask the daemon to reconnect to OBS", json: true, build: ->(_args : Array(String)) do ReconnectCommand.new.as(Command) end), CommandSpec.new(name: "shutdown-server", summary: "Ask the daemon to shut down", json: true, build: ->(_args : Array(String)) do ShutdownServerCommand.new.as(Command) end), CommandSpec.new(name: "scene", aliases: ["set-scene"], summary: "Switch the current program scene", arguments: [ArgumentKind::Scene], json: true, build: ->(args : Array(String)) do (SetSceneCommand.new(args[0])).as(Command) end), CommandSpec.new(name: "profile", aliases: ["set-profile"], summary: "Switch the active profile", arguments: [ArgumentKind::Profile], json: true, build: ->(args : Array(String)) do (SetProfileCommand.new(args[0])).as(Command) end), CommandSpec.new(name: "collection", aliases: ["set-collection", "scene-collection"], summary: "Switch the active scene collection", arguments: [ArgumentKind::SceneCollection], json: true, build: ->(args : Array(String)) do (SetSceneCollectionCommand.new(args[0])).as(Command) end), CommandSpec.new(name: "mute", summary: "Mute an audio input", arguments: [ArgumentKind::AudioInput], json: true, build: ->(args : Array(String)) do (MuteCommand.new(args[0])).as(Command) end), CommandSpec.new(name: "unmute", summary: "Unmute an audio input", arguments: [ArgumentKind::AudioInput], json: true, build: ->(args : Array(String)) do (UnmuteCommand.new(args[0])).as(Command) end), CommandSpec.new(name: "toggle-mute", summary: "Toggle mute for an audio input", arguments: [ArgumentKind::AudioInput], json: true, build: ->(args : Array(String)) do (ToggleMuteCommand.new(args[0])).as(Command) end), CommandSpec.new(name: "vol", aliases: ["volume"], summary: "Set an audio input's volume percentage", arguments: [ArgumentKind::AudioInput, ArgumentKind::Percent], json: true, build: ->(args : Array(String)) do (VolumeCommand.new(args[0], CommandRegistry.parse_percent(args[1]))).as(Command) end), CommandSpec.new(name: "stream", summary: "Toggle streaming", json: true, build: ->(_args : Array(String)) do ToggleStreamCommand.new.as(Command) end), CommandSpec.new(name: "rec", aliases: ["record"], summary: "Control the recording output", arguments: [ArgumentKind::RecordAction], required_arguments: 0, json: true, build: ->(args : Array(String)) do CommandRegistry.build_record(args) end), CommandSpec.new(name: "dump-config", summary: "Merge live OBS names into the config file", json: true, build: ->(_args : Array(String)) do DumpConfigCommand.new.as(Command) end), CommandSpec.new(name: "reload-config", summary: "Reload the daemon's config from disk", json: true, build: ->(_args : Array(String)) do ReloadConfigCommand.new.as(Command) end), CommandSpec.new(name: "validate-config", summary: "Validate the config file", json: true, build: ->(_args : Array(String)) do ValidateConfigCommand.new.as(Command) end)]
Instance Method Summary
-
#[]?(name : String) : CommandSpec | Nil
Resolves one spelling, case-insensitively and with any leading slash.
- #build_record(args : Array(String)) : Command
-
#cli_names : Array(String)
Canonical CLI names, for shell completion and usage errors.
-
#cli_spellings : Array(String)
Every accepted CLI spelling, aliases included.
-
#for_surface(surface : CommandSurface) : Array(CommandSpec)
Specs offered on the given surface, in declaration order.
-
#help_lines(surface : CommandSurface, prefix : String = "") : Array(String)
One-line-per-command help, aligned on the usage column.
-
#json?(name : String | Nil) : Bool
True when the CLI can render this command as a JSON envelope.
-
#normalize(name : String) : String
Strips the palette prefix so
/sceneandsceneresolve alike. -
#palette_names : Array(String)
Canonical palette names, slash-prefixed, for completion.
- #parse_percent(value : String) : Int32
Instance Method Detail
Resolves one spelling, case-insensitively and with any leading slash.
Specs offered on the given surface, in declaration order.
One-line-per-command help, aligned on the usage column.
True when the CLI can render this command as a JSON envelope.
Strips the palette prefix so /scene and scene resolve alike.
Canonical palette names, slash-prefixed, for completion.
Aliases stay parseable but are left out of suggestions: offering both
/collection and /scene-collection for /sc is noise, not help.