-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
86 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from textual import on | ||
from textual.widgets import OptionList | ||
from textual.widgets.option_list import Option | ||
|
||
from models import Project | ||
from models.project import ProjectAction | ||
from .terminal import ShellCommand, NonShellCommand, CommandType | ||
from .message import TerminalCommandRequested | ||
|
||
|
||
class ActionOptionList(OptionList): | ||
# BORDER_TITLE = "Commands" | ||
|
||
# def __init__(self, project: Project, **kwargs): | ||
def __init__( | ||
self, | ||
project: Project, | ||
actions: list[ProjectAction], | ||
group_name: str = "Commands", | ||
**kwargs | ||
): | ||
self._project: Project = project | ||
self._actions: list[ProjectAction] = actions | ||
super().__init__(*(Option(action.label) for action in self._actions), **kwargs) | ||
self.border_title = group_name | ||
|
||
@on(OptionList.OptionSelected) | ||
def on_script_selected(self, event: OptionList.OptionSelected) -> None: | ||
action = self._actions[event.option_index] | ||
command: CommandType = ( | ||
ShellCommand(path=self._project.path, command=action.command) | ||
if action.use_shell | ||
else NonShellCommand( | ||
path=self._project.path, command=action.command.split(" ") | ||
) | ||
) | ||
self.post_message(TerminalCommandRequested(command=command)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from textual.message import Message | ||
|
||
from .terminal import CommandType | ||
|
||
|
||
class TerminalCommandRequested(Message): | ||
def __init__( | ||
self, | ||
command: CommandType, | ||
allow_rerun: bool = True, | ||
): | ||
self.command = command | ||
self.allow_rerun = allow_rerun | ||
super().__init__() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters