Command
Command
Bases: ABC
Base class for the Commands for the shell widget.
Source code in src/textual_shell/command.py
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 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
DEFINITION
abstractmethod
property
Abstract property for representing the command definition. Subclasses must provide their own definitions as a dictionary mapping node names to CommandNode instances.
Log
Bases: Message
Default Logging event for commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sender
|
str
|
The name of the command sending the log. |
required |
msg
|
str
|
The log message. |
required |
severity
|
int
|
The level of the severity. |
required |
Source code in src/textual_shell/command.py
create_job(*args)
abstractmethod
Create a job to execute the command. Subclasses must implement it.
Returns:
| Name | Type | Description |
|---|---|---|
job |
Job
|
The created job ready for execution. |
get_help_render(root)
Generate the rich markup for the help box.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
CommandNode
|
The root of the commands definition. |
required |
Yields:
| Name | Type | Description |
|---|---|---|
group |
Group
|
The rich renderable components for the command definition. |
Source code in src/textual_shell/command.py
get_root()
Get the root of the Command Definition.
Returns:
| Name | Type | Description |
|---|---|---|
root |
CommandNode
|
The root of the Command. |
get_suggestions(cmdline)
Get a list of suggestions for autocomplete via the current args neighbors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmdline
|
list[str]
|
The current value of the command line. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
suggestions |
list[str]
|
List of possible next values. |
Source code in src/textual_shell/command.py
help()
Generate the rich.panel to display in the Help modals RichLog widget.
Returns:
| Name | Type | Description |
|---|---|---|
panel |
Panel
|
The panel with the help for the command. |
Source code in src/textual_shell/command.py
send_log(msg, severity)
Send logs from the command to the console log.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
str
|
The message for the log. |
required |
severity
|
int
|
The severity level for the log. Uses the same levels as the logging module. |
required |
Source code in src/textual_shell/command.py
CommandNode
Nodes for the command Definition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name for the node. |
required |
description
|
str
|
The description for the node. |
required |
value
|
Optional[str]
|
Optional value for the node |
None
|
options
|
Optional[list[str] | dict[str, str]]
|
Optional values for the node. |
None
|
children
|
Optional[dict[str, CommandNode]]
|
Optional dictionary of child nodes. |
None
|
Source code in src/textual_shell/command.py
get_options()
Retrieve the nodes options for it value. If options is a dictionary then the keys are returned.
Returns:
| Name | Type | Description |
|---|---|---|
options |
list[str]
|
The options. |