app
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| SlashedApp slashed.textual_adapter.app Base app with slash command support. |
||
| TextualOutputWriter slashed.textual_adapter.app Output writer that routes messages to bound widgets. |
🛈 DocStrings¶
Textual suggester adapter for Slashed.
SlashedApp
¶
Bases: App[TResult]
Base app with slash command support.
This app provides slash command functionality with optional typed context data. Commands can access the context data through self.context.get_data().
Class Type Parameters:
| Name | Bound or Constraints | Description | Default |
|---|---|---|---|
TContext
|
Type of the command context data. When using typed context, access it via self.context.get_data() to get proper type checking. |
required | |
TResult
|
Type of value returned by app.run(). Use None if the app doesn't return anything. |
required |
Example
Source code in src/slashed/textual_adapter/app.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
__init__
¶
__init__(
store: CommandStore | None = None,
data: TContext | None = None,
commands: list[type[SlashedCommand] | BaseCommand] | None = None,
*args: Any,
**kwargs: Any,
) -> None
Initialize app with command store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
TContext | None
|
Optional context data |
None
|
commands
|
list[type[SlashedCommand] | BaseCommand] | None
|
Optional list of commands to register |
None
|
store
|
CommandStore | None
|
Optional command store (creates new one if not provided) |
None
|
*args
|
Any
|
Arguments passed to textual.App |
()
|
**kwargs
|
Any
|
Keyword arguments passed to textual.App |
{}
|
Source code in src/slashed/textual_adapter/app.py
bind_output
¶
Bind an output stream to a widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_id
|
str
|
ID for this output stream |
required |
widget_query
|
str
|
CSS query to find the target widget |
required |
default
|
bool
|
Whether this is the default output |
False
|
Source code in src/slashed/textual_adapter/app.py
command_input
classmethod
¶
command_input(
input_id: str,
) -> Callable[[Callable[[Any, str], Awaitable[None]]], Callable[[Any, str], Awaitable[None]]]
Register an Input widget to handle commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_id
|
str
|
ID of the Input widget that should handle commands |
required |
Example
Source code in src/slashed/textual_adapter/app.py
get_suggester
¶
get_suggester() -> SlashedSuggester
on_input_submitted
async
¶
Handle input submission.
Source code in src/slashed/textual_adapter/app.py
TextualOutputWriter
¶
Bases: OutputWriter
Output writer that routes messages to bound widgets.
Supports different widget types: - Labels: Direct update of content - VerticalScroll/Container: Mount new Label with content - Other widgets: Try update() method
Source code in src/slashed/textual_adapter/app.py
bind
¶
Bind an output to a widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_id
|
str
|
ID for this output stream |
required |
widget_query
|
str
|
CSS query to find the target widget |
required |
default
|
bool
|
Whether this is the default output for unspecified streams |
False
|
Source code in src/slashed/textual_adapter/app.py
print
async
¶
Print message to bound widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Message to display |
required |
output_id
|
str | None
|
Optional output stream ID. Uses default if not specified. |
None
|
The message is handled differently based on widget type: - For containers (VerticalScroll/Container): Mount new Label - For Label widgets: Update content - For other widgets: Try update() method
Raises:
| Type | Description |
|---|---|
ValueError
|
If no default binding is configured or binding not found |
TypeError
|
If widget type is not supported |