RunCommand
Base classes
| Name |
Children |
Inherits |
SlashedCommand slashed.commands Base class for declarative commands. |
|
|
⋔ Inheritance diagram
graph TD
2561908768["system.RunCommand"]
807245086["commands.SlashedCommand"]
900363605["base.BaseCommand"]
925645236["abc.ABC"]
2751680898["builtins.object"]
807245086 --> 2561908768
900363605 --> 807245086
925645236 --> 900363605
2751680898 --> 925645236
🛈 DocStrings
Bases: SlashedCommand
Launch a system command asynchronously.
Usage
/run [args...]
The command runs in the background without blocking.
Source code in src/slashed/builtin/system.py
| class RunCommand(SlashedCommand):
"""Launch a system command asynchronously.
Usage:
/run <command> [args...]
The command runs in the background without blocking.
"""
name = "run"
category = "system"
raw_args = True
def get_completer(self) -> PathCompleter:
"""Get path completer for executables."""
return PathCompleter(directories=True, files=True)
async def execute_command(
self,
ctx: CommandContext[Any],
command: str,
*args: str,
) -> None:
"""Launch system command asynchronously."""
try:
process = await asyncio.create_subprocess_exec(
command,
*args,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
await ctx.print(f"✅ Started process **{process.pid}**")
except FileNotFoundError as e:
msg = f"Command not found: {command}"
raise CommandError(msg) from e
|
execute_command
async
execute_command(ctx: CommandContext[Any], command: str, *args: str) -> None
Launch system command asynchronously.
Source code in src/slashed/builtin/system.py
| async def execute_command(
self,
ctx: CommandContext[Any],
command: str,
*args: str,
) -> None:
"""Launch system command asynchronously."""
try:
process = await asyncio.create_subprocess_exec(
command,
*args,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
await ctx.print(f"✅ Started process **{process.pid}**")
except FileNotFoundError as e:
msg = f"Command not found: {command}"
raise CommandError(msg) from e
|
get_completer
Get path completer for executables.
Source code in src/slashed/builtin/system.py
| def get_completer(self) -> PathCompleter:
"""Get path completer for executables."""
return PathCompleter(directories=True, files=True)
|
:fa-brands-github: Show source on GitHub