Skip to content

Commit 8666c07

Browse files
authored
♻️ Massive refactor / organization (#840)
References to "config" are now "workspace" Organize files: - `cli/utils.py` functions moved to `workspace/finders.py` - `config.py` split between: - `workspace/finders.py` - `workspace/freezer.py` - `workspace/importers.py` - `workspace/validation.py` - `workspacebuilder.py` split into: - `workspace/builder.py` - `workspace/freezer.py` `config.inline` moved to freezer Tests: - `tests/fixtures/{workspacebuilder,workspacefreezer}` -> `tests/fixtures/workspace/{builder,freezer}` - `tests/test_import_{teamocil,tmuxinator}.py` -> `tests/workspace/test_import_{teamocil,tmuxinator}.py`
2 parents b8befec + 1c2fe29 commit 8666c07

File tree

111 files changed

+1883
-1770
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1883
-1770
lines changed

CHANGES

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,34 @@ $ pipx install --suffix=@next 'tmuxp' --pip-args '\--pre' --force
2121

2222
<!-- Maintainers, insert changes / features for the next release here -->
2323

24+
### Internal refactoring (#840)
25+
26+
#### Rename config to workspace
27+
28+
Reference to "config" are now "workspace"
29+
30+
#### Organize files
31+
32+
- `cli/utils.py` functions moved to `workspace/finders.py`
33+
- `config.py` split between:
34+
35+
- `workspace/finders.py`
36+
- `workspace/freezer.py`
37+
- `workspace/importers.py`
38+
- `workspace/validation.py`
39+
40+
- `workspacebuilder.py` split into:
41+
42+
- `workspace/builder.py`
43+
- `workspace/freezer.py`
44+
45+
`config.inline` moved to freezer
46+
47+
#### Tests
48+
49+
- `tests/fixtures/{workspacebuilder,workspacefreezer}` -> `tests/fixtures/workspace/{builder,freezer}`
50+
- `tests/test_import_{teamocil,tmuxinator}.py` -> `tests/workspace/test_import_{teamocil,tmuxinator}.py`
51+
2452
## tmuxp 1.17.3 (2022-10-30)
2553

2654
**Maintenance release, no features or fixes**

conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from libtmux.test import namer
1717
from tests.fixtures import utils as test_utils
18-
from tmuxp.cli.utils import get_config_dir
18+
from tmuxp.workspace.finders import get_workspace_dir
1919

2020
if t.TYPE_CHECKING:
2121
from libtmux.session import Session
@@ -56,7 +56,7 @@ def tmuxp_configdir_default(
5656
monkeypatch: pytest.MonkeyPatch, tmuxp_configdir: pathlib.Path
5757
) -> None:
5858
monkeypatch.setenv("TMUXP_CONFIGDIR", str(tmuxp_configdir))
59-
assert get_config_dir() == str(tmuxp_configdir)
59+
assert get_workspace_dir() == str(tmuxp_configdir)
6060

6161

6262
@pytest.fixture(scope="function")

docs/about.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ from JSON and YAML.
9494
- `$ tmuxp -2`, `$ tmuxp -8` for forcing term colors a la
9595
{term}`tmux(1)`.
9696
- `$ tmuxp -L<socket-name>`, `$ tmuxp -S<socket-path>` for sockets and
97-
`$ tmuxp -f<config-file>` for config file.
97+
`$ tmuxp -f <workspace-file>` for config file.
9898

9999
[attempt at 1.7 test]: https://travis-ci.org/tmux-python/tmuxp/jobs/12348263
100100
[mit-licensed]: http://opensource.org/licenses/MIT

docs/api.md

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ If you need an internal API stabilized please [file an issue](https://github.com
4545

4646
## CLI
4747

48-
```{eval-rst}
49-
.. automethod:: tmuxp.cli.utils.get_config_dir
50-
```
51-
5248
```{eval-rst}
5349
.. automethod:: tmuxp.cli.import_config.get_teamocil_dir
5450
```
@@ -65,50 +61,54 @@ If you need an internal API stabilized please [file an issue](https://github.com
6561
.. automethod:: tmuxp.cli.load._reattach
6662
```
6763

68-
## Configuration
64+
## Workspace files
6965

7066
### Finding
7167

7268
```{eval-rst}
73-
.. automethod:: tmuxp.config.is_config_file
69+
.. automethod:: tmuxp.workspace.finders.is_workspace_file
7470
```
7571

7672
```{eval-rst}
77-
.. automethod:: tmuxp.config.in_dir
73+
.. automethod:: tmuxp.workspace.finders.in_dir
7874
```
7975

8076
```{eval-rst}
81-
.. automethod:: tmuxp.config.in_cwd
77+
.. automethod:: tmuxp.workspace.finders.in_cwd
8278
```
8379

84-
### Import and export
85-
8680
```{eval-rst}
87-
.. automethod:: tmuxp.config.validate_schema
81+
.. automethod:: tmuxp.workspace.finders.get_workspace_dir
8882
```
8983

84+
### Validation
85+
9086
```{eval-rst}
91-
.. automethod:: tmuxp.config.expandshell
87+
.. autofunction:: tmuxp.workspace.validation.validate_schema
9288
```
9389

90+
### Processing
91+
9492
```{eval-rst}
95-
.. automethod:: tmuxp.config.expand
93+
.. automethod:: tmuxp.workspace.loader.expandshell
9694
```
9795

9896
```{eval-rst}
99-
.. automethod:: tmuxp.config.inline
97+
.. automethod:: tmuxp.workspace.loader.expand
10098
```
10199

102100
```{eval-rst}
103-
.. automethod:: tmuxp.config.trickle
101+
.. automethod:: tmuxp.workspace.loader.trickle
104102
```
105103

104+
## Workspace importers
105+
106106
```{eval-rst}
107-
.. automethod:: tmuxp.config.import_teamocil
107+
.. automethod:: tmuxp.workspace.importers.import_teamocil
108108
```
109109

110110
```{eval-rst}
111-
.. automethod:: tmuxp.config.import_tmuxinator
111+
.. automethod:: tmuxp.workspace.importers.import_tmuxinator
112112
```
113113

114114
## Configuration reader
@@ -120,22 +120,28 @@ If you need an internal API stabilized please [file an issue](https://github.com
120120
## Workspace Builder
121121

122122
```{eval-rst}
123-
.. autoclass:: tmuxp.workspacebuilder.WorkspaceBuilder
123+
.. autoclass:: tmuxp.workspace.builder.WorkspaceBuilder
124124
:members:
125125
```
126126

127+
## Workspace Freezer
128+
129+
```{eval-rst}
130+
.. automethod:: tmuxp.workspace.freezer.freeze
131+
```
132+
127133
```{eval-rst}
128-
.. automethod:: tmuxp.workspacebuilder.freeze
134+
.. automethod:: tmuxp.workspace.freezer.inline
129135
```
130136

131137
## Exceptions
132138

133139
```{eval-rst}
134-
.. autoexception:: tmuxp.exc.EmptyConfigException
140+
.. autoexception:: tmuxp.exc.EmptyWorkspaceException
135141
```
136142

137143
```{eval-rst}
138-
.. autoexception:: tmuxp.exc.ConfigError
144+
.. autoexception:: tmuxp.exc.WorkspaceError
139145
```
140146

141147
```{eval-rst}

docs/cli/freeze.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ Tmuxp will offer to save your session state to `.json` or `.yaml`.
3434

3535
If no session is specified, it will default to the attached session.
3636

37-
If the `--force` argument is passed, it will overwrite any existing config file with the same name.
37+
If the `--force` argument is passed, it will overwrite any existing workspace file with the same name.

docs/cli/load.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ $ tmuxp load [filename]
8484

8585
## Inside sessions
8686

87-
If you try to load a config file from within a tmux session, it will ask you
87+
If you try to load a workspace file from within a tmux session, it will ask you
8888
if you want to load and attach to the new session, or just load detached.
89-
You can also load a config file and append the windows to the current active session.
89+
You can also load a workspace file and append the windows to the current active session.
9090

9191
```
9292
Already inside TMUX, switch to session? yes/no

docs/configuration/examples.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ Edit this page.
699699
- <https://github.com/tony/sphinxcontrib-github/blob/master/.tmuxp.yaml>
700700

701701
You can use `start_directory: ./` to make the directories relative to
702-
the config file / project root.
702+
the workspace file / project root.
703703

704704
## Bonus: pipenv auto-bootstrapping
705705

@@ -761,8 +761,8 @@ windows:
761761

762762
tmuxp sessions can be scripted in python. The first way is to use the
763763
ORM in the {ref}`API`. The second is to pass a {py:obj}`dict` into
764-
{class}`~tmuxp.workspacebuilder.WorkspaceBuilder` with a correct schema.
765-
See: {meth}`tmuxp.config.validate_schema`.
764+
{class}`~tmuxp.workspace.builder.WorkspaceBuilder` with a correct schema.
765+
See: {meth}`tmuxp.validation.validate_schema`.
766766

767767
:::
768768

docs/configuration/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# Configuration
66

7-
tmuxp loads your terminal workspace into tmux using config files.
7+
tmuxp loads your terminal workspace into tmux using workspace files.
88

99
The configuration file can be JSON or YAML. It's declarative style resembles tmux's object hierarchy: session, window and wanes.
1010

@@ -24,7 +24,7 @@ tmuxp will offers to assist when:
2424
- _When inside a tmux client_, `tmuxp` will let you create a new session and switch to it, or append the windows to your existing
2525
session.
2626

27-
## What's in a config file?
27+
## What's in a workspace file?
2828

2929
1. A session name
3030
2. A list of _windows_
@@ -98,14 +98,14 @@ Breaking down the basic configuration into sections:
9898
# command options
9999
```
100100

101-
## Where do I store config files?
101+
## Where do I store workspace files?
102102

103103
### Direct
104104

105105
You can create a configuration and load it from anywhere in your file system.
106106

107107
```console
108-
$ tmuxp load [config_file]
108+
$ tmuxp load [workspace-file]
109109
```
110110

111111
````{tab} Relative

docs/configuration/top-level.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Used for:
1212

1313
Notes:
1414

15-
- Session names may differ from config filename.
15+
- Session names may differ from workspace filename.
1616

1717
e.g. _apple.yaml_:
1818

docs/developing.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,19 @@ $ env PYTEST_ADDOPTS="-verbose" make start
159159
Pick a file:
160160

161161
```console
162-
$ env PYTEST_ADDOPTS="tests/test_workspacebuilder.py" poetry run make start
162+
$ env PYTEST_ADDOPTS="tests/workspace/test_builder.py" poetry run make start
163163
```
164164

165-
Drop into `test_automatic_rename_option()` in `tests/test_workspacebuilder.py`:
165+
Drop into `test_automatic_rename_option()` in `tests/workspace/test_builder.py`:
166166

167167
```console
168-
$ env PYTEST_ADDOPTS="-s -x -vv tests/test_workspacebuilder.py" poetry run make start
168+
$ env PYTEST_ADDOPTS="-s -x -vv tests/workspace/test_builder.py" poetry run make start
169169
```
170170

171-
Drop into `test_automatic_rename_option()` in `tests/test_workspacebuilder.py` and stop on first error:
171+
Drop into `test_automatic_rename_option()` in `tests/workspace/test_builder.py` and stop on first error:
172172

173173
```console
174-
$ env PYTEST_ADDOPTS="-s -x -vv tests/test_workspacebuilder.py::test_automatic_rename_option" poetry run make start
174+
$ env PYTEST_ADDOPTS="-s -x -vv tests/workspace/test_builder.py::test_automatic_rename_option" poetry run make start
175175
```
176176

177177
Drop into `pdb` on first error:
@@ -237,7 +237,7 @@ Create two terminals:
237237
version of tmuxp above. Then:
238238

239239
```console
240-
$ py.test tests/test_workspacebuilder.py
240+
$ py.test tests/workspace/test_builder.py
241241
```
242242

243243
Terminal 1 should have flickered and built the session before your eyes.

examples/start-directory.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
{
5252
"shell_command": [
5353
"echo '\\033c",
54-
"./ is relative to config file location",
55-
"../ will be parent of config file",
56-
"./test will be \\\"test\\\" dir inside dir of config file'"
54+
"./ is relative to workspace file location",
55+
"../ will be parent of workspace file",
56+
"./test will be \\\"test\\\" dir inside dir of workspace file'"
5757
]
5858
},
5959
{

examples/start-directory.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ windows:
2626
panes:
2727
- echo '\033c absolute paths also have precedence.'
2828
- echo hello
29-
- window_name: should be config's dir
29+
- window_name: should be workspace file's dir
30+
3031
start_directory: ./
3132
panes:
3233
- shell_command:
3334
- echo '\033c
34-
- ./ is relative to config file location
35-
- ../ will be parent of config file
36-
- ./test will be \"test\" dir inside dir of config file'
35+
- ./ is relative to workspace file location
36+
- ../ will be parent of workspace file
37+
- ./test will be \"test\" dir inside dir of workspace file'
3738
- shell_command:
3839
- echo '\033c
3940
- This way you can load up workspaces from projects and maintain

src/tmuxp/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
:license: MIT, see LICENSE for details
99
1010
"""
11-
from . import cli, config, util
11+
from . import cli, util
1212
from .__about__ import (
1313
__author__,
1414
__copyright__,

0 commit comments

Comments
 (0)