Skip to content

Commit 7466b20

Browse files
committed
!squash wip
1 parent 6131241 commit 7466b20

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

src/tmuxp/_internal/types.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ class PaneConfig(TypedDict, total=False):
5959
environment: NotRequired[dict[str, str]]
6060
focus: NotRequired[str | bool]
6161
suppress_history: NotRequired[bool]
62+
target: NotRequired[str]
6263

6364

64-
PaneValue = t.Union[str, PaneConfig]
65+
PaneValue = t.Union[str, PaneConfig, None]
6566

6667

6768
class WindowConfig(TypedDict, total=False):
@@ -70,7 +71,9 @@ class WindowConfig(TypedDict, total=False):
7071
window_name: str
7172
start_directory: NotRequired[str]
7273
shell_command_before: NotRequired[ShellCommandValue]
74+
shell_command_after: NotRequired[ShellCommandValue]
7375
layout: NotRequired[str]
76+
clear: NotRequired[bool]
7477
options: NotRequired[dict[str, t.Any]]
7578
options_after: NotRequired[dict[str, t.Any]]
7679
environment: NotRequired[dict[str, str]]

src/tmuxp/cli/import_config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def create_import_subparser(
134134
class ImportConfigFn(t.Protocol):
135135
"""Typing for import configuration callback function."""
136136

137-
def __call__(self, workspace_dict: dict[str, t.Any]) -> dict[str, t.Any]:
137+
def __call__(self, workspace_dict: dict[str, t.Any]) -> WorkspaceConfig:
138138
"""Execute tmuxp import function."""
139139
...
140140

@@ -146,7 +146,9 @@ def import_config(
146146
) -> None:
147147
"""Import a configuration from a workspace_file."""
148148
existing_workspace_file = ConfigReader._from_file(pathlib.Path(workspace_file))
149-
cfg_reader = ConfigReader(importfunc(existing_workspace_file))
149+
cfg_reader = ConfigReader(
150+
t.cast(dict[t.Any, t.Any], importfunc(existing_workspace_file))
151+
)
150152

151153
workspace_file_format = prompt_choices(
152154
"Convert to",

src/tmuxp/workspace/importers.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def import_tmuxinator(workspace_dict: dict[str, t.Any]) -> WorkspaceConfig:
5555
if "socket_name" in workspace_dict:
5656
tmuxp_workspace["socket_name"] = workspace_dict["socket_name"]
5757

58-
5958
if "tabs" in workspace_dict:
6059
workspace_dict["windows"] = workspace_dict.pop("tabs")
6160

@@ -92,14 +91,10 @@ def import_tmuxinator(workspace_dict: dict[str, t.Any]) -> WorkspaceConfig:
9291
for k, v in window_item.items():
9392
new_window: WindowConfig = {"window_name": k}
9493

95-
if isinstance(v, str):
94+
if isinstance(v, str) or v is None:
9695
new_window["panes"] = [v]
9796
tmuxp_workspace["windows"].append(new_window)
9897
continue
99-
if v is None:
100-
new_window["panes"] = [""] # Empty pane
101-
tmuxp_workspace["windows"].append(new_window)
102-
continue
10398
if isinstance(v, list):
10499
new_window["panes"] = v
105100
tmuxp_workspace["windows"].append(new_window)
@@ -153,20 +148,17 @@ def import_teamocil(workspace_dict: dict[str, t.Any]) -> WorkspaceConfig:
153148
if "root" in workspace_dict:
154149
tmuxp_workspace["start_directory"] = workspace_dict.pop("root")
155150

156-
157151
for w in workspace_dict["windows"]:
158152
window_dict: WindowConfig = {"window_name": w["name"]}
159153

160154
if "clear" in w:
161-
# TODO: handle clear attribute
162-
pass
155+
window_dict["clear"] = w["clear"]
163156

164157
if "filters" in w:
165158
if "before" in w["filters"]:
166159
window_dict["shell_command_before"] = w["filters"]["before"]
167160
if "after" in w["filters"]:
168-
# TODO: handle shell_command_after
169-
pass
161+
window_dict["shell_command_after"] = w["filters"]["after"]
170162

171163
if "root" in w:
172164
window_dict["start_directory"] = w.pop("root")

0 commit comments

Comments
 (0)