Skip to content

Command options #752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,31 @@

- Fix loading of `.yml` files with `tmuxp convert`, thank you @kalixi! (#725)

#### Internal API

- #752: Command structure (internal API)

To pave the way for per-command options such as `enter: false` (#52), commands are now a different format:

Before, [`str`](str):

```python
"echo hello"
```

After, [`dict`](dict):

```python
{
"cmd": "echo hello"
}
```

This is purely internal. Normal usage should be the same since the
configuration emits the equivalent result.

- #752: Configuration parsing refactorings

#### Development

- Run through black + isort with string normalization (#738). This way we can
Expand Down
21 changes: 12 additions & 9 deletions tests/fixtures/config/expand1.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,39 +36,42 @@
{
"window_name": "editor",
"panes": [
{"shell_command": ["vim", "top"]},
{"shell_command": ["vim"]},
{"shell_command": ['cowsay "hey"']},
{"shell_command": [{"cmd": "vim"}, {"cmd": "top"}]},
{"shell_command": [{"cmd": "vim"}]},
{"shell_command": [{"cmd": 'cowsay "hey"'}]},
],
"layout": "main-verticle",
},
{
"window_name": "logging",
"panes": [{"shell_command": ["tail -F /var/log/syslog"]}],
"panes": [{"shell_command": [{"cmd": "tail -F /var/log/syslog"}]}],
},
{
"start_directory": "/var/log",
"options": {"automatic-rename": True},
"panes": [{"shell_command": ["htop"]}, {"shell_command": ["vim"]}],
"panes": [
{"shell_command": [{"cmd": "htop"}]},
{"shell_command": [{"cmd": "vim"}]},
],
},
{
"start_directory": os.path.normpath(
os.path.join(os.path.expanduser("~"), "./")
),
"panes": [{"shell_command": ["pwd"]}],
"panes": [{"shell_command": [{"cmd": "pwd"}]}],
},
{
"start_directory": os.path.normpath(
os.path.join(os.path.expanduser("~"), "./asdf")
),
"panes": [{"shell_command": ["pwd"]}],
"panes": [{"shell_command": [{"cmd": "pwd"}]}],
},
{
"start_directory": os.path.normpath(
os.path.join(os.path.expanduser("~"), "../")
),
"panes": [{"shell_command": ["pwd"]}],
"panes": [{"shell_command": [{"cmd": "pwd"}]}],
},
{"panes": [{"shell_command": ["top"]}]},
{"panes": [{"shell_command": [{"cmd": "top"}]}]},
],
}
18 changes: 9 additions & 9 deletions tests/fixtures/config/expand2-expanded.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ windows:
focus: true
panes:
- shell_command:
- cd ~
- cmd: cd ~
- shell_command:
- cd /usr
- cmd: cd /usr
focus: true
- shell_command:
- cd ~
- echo "moo"
- top
- cmd: cd ~
- cmd: echo "moo"
- cmd: top
- window_name: window 2
panes:
- shell_command:
- top
- cmd: top
focus: true
- shell_command:
- echo "hey"
- cmd: echo "hey"
- shell_command:
- echo "moo"
- cmd: echo "moo"
- window_name: window 3
panes:
- shell_command:
- cd /
- cmd: cd /
focus: true
- shell_command: []
- shell_command: []
6 changes: 3 additions & 3 deletions tests/fixtures/config/expand_blank.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
{
"window_name": "Empty string (return)",
"panes": [
{"shell_command": [""]},
{"shell_command": [""]},
{"shell_command": [""]},
{"shell_command": [{"cmd": ""}]},
{"shell_command": [{"cmd": ""}]},
{"shell_command": [{"cmd": ""}]},
],
},
{
Expand Down
75 changes: 52 additions & 23 deletions tests/fixtures/config/shell_command_before.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,46 @@
{
"window_name": "editor",
"start_directory": os.path.expanduser("~"),
"shell_command_before": ["source .venv/bin/activate"],
"shell_command_before": {
"shell_command": [{"cmd": "source .venv/bin/activate"}]
},
"panes": [
{"shell_command": ["vim"]},
{"shell_command": [{"cmd": "vim"}]},
{
"shell_command_before": ["rbenv local 2.0.0-p0"],
"shell_command": ['cowsay "hey"'],
"shell_command_before": {
"shell_command": [{"cmd": "rbenv local 2.0.0-p0"}]
},
"shell_command": [{"cmd": 'cowsay "hey"'}],
},
],
"layout": "main-verticle",
},
{
"shell_command_before": ["rbenv local 2.0.0-p0"],
"shell_command_before": {
"shell_command": [{"cmd": "rbenv local 2.0.0-p0"}]
},
"window_name": "logging",
"panes": [
{"shell_command": ["tail -F /var/log/syslog"]},
{"shell_command": [{"cmd": "tail -F /var/log/syslog"}]},
{"shell_command": []},
],
},
{
"window_name": "shufu",
"panes": [
{
"shell_command_before": ["rbenv local 2.0.0-p0"],
"shell_command": ["htop"],
"shell_command_before": {
"shell_command": [{"cmd": "rbenv local 2.0.0-p0"}]
},
"shell_command": [{"cmd": "htop"}],
}
],
},
{"options": {"automatic-rename": True}, "panes": [{"shell_command": ["htop"]}]},
{"panes": [{"shell_command": ["top"]}]},
{
"options": {"automatic-rename": True},
"panes": [{"shell_command": [{"cmd": "htop"}]}],
},
{"panes": [{"shell_command": [{"cmd": "top"}]}]},
],
}

Expand All @@ -82,44 +93,62 @@
{
"window_name": "editor",
"start_directory": os.path.expanduser("~"),
"shell_command_before": ["source .venv/bin/activate"],
"shell_command_before": {
"shell_command": [{"cmd": "source .venv/bin/activate"}]
},
"panes": [
{"shell_command": ["source .venv/bin/activate", "vim"]},
{
"shell_command_before": ["rbenv local 2.0.0-p0"],
"shell_command": [
"source .venv/bin/activate",
"rbenv local 2.0.0-p0",
'cowsay "hey"',
{"cmd": "source .venv/bin/activate"},
{"cmd": "vim"},
]
},
{
"shell_command_before": {
"shell_command": [{"cmd": "rbenv local 2.0.0-p0"}]
},
"shell_command": [
{"cmd": "source .venv/bin/activate"},
{"cmd": "rbenv local 2.0.0-p0"},
{"cmd": 'cowsay "hey"'},
],
},
],
"layout": "main-verticle",
},
{
"shell_command_before": ["rbenv local 2.0.0-p0"],
"shell_command_before": {
"shell_command": [{"cmd": "rbenv local 2.0.0-p0"}]
},
"start_directory": "/",
"window_name": "logging",
"panes": [
{"shell_command": ["rbenv local 2.0.0-p0", "tail -F /var/log/syslog"]},
{"shell_command": ["rbenv local 2.0.0-p0"]},
{
"shell_command": [
{"cmd": "rbenv local 2.0.0-p0"},
{"cmd": "tail -F /var/log/syslog"},
]
},
{"shell_command": [{"cmd": "rbenv local 2.0.0-p0"}]},
],
},
{
"start_directory": "/",
"window_name": "shufu",
"panes": [
{
"shell_command_before": ["rbenv local 2.0.0-p0"],
"shell_command": ["rbenv local 2.0.0-p0", "htop"],
"shell_command_before": {
"shell_command": [{"cmd": "rbenv local 2.0.0-p0"}]
},
"shell_command": [{"cmd": "rbenv local 2.0.0-p0"}, {"cmd": "htop"}],
}
],
},
{
"start_directory": "/",
"options": {"automatic-rename": True},
"panes": [{"shell_command": ["htop"]}],
"panes": [{"shell_command": [{"cmd": "htop"}]}],
},
{"start_directory": "/", "panes": [{"shell_command": ["top"]}]},
{"start_directory": "/", "panes": [{"shell_command": [{"cmd": "top"}]}]},
],
}
23 changes: 12 additions & 11 deletions tests/fixtures/config/shell_command_before_session-expected.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
shell_command_before:
- 'echo "hi"'
shell_command:
- cmd: 'echo "hi"'
session_name: 'test'
windows:
- window_name: editor
panes:
- shell_command:
- 'echo "hi"'
- vim
- :Ex
- cmd: 'echo "hi"'
- cmd: vim
- cmd: :Ex
- shell_command:
- 'echo "hi"'
- cmd: 'echo "hi"'
- shell_command:
- 'echo "hi"'
- cd /usr
- cmd: 'echo "hi"'
- cmd: cd /usr
- window_name: logging
panes:
- shell_command:
- 'echo "hi"'
- cmd: 'echo "hi"'
- shell_command:
- 'echo "hi"'
- top
- emacs
- cmd: 'echo "hi"'
- cmd: top
- cmd: emacs
14 changes: 10 additions & 4 deletions tests/fixtures/config/trickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
{
"window_name": "editor",
"start_directory": "log",
"panes": [{"shell_command": ["vim"]}, {"shell_command": ['cowsay "hey"']}],
"panes": [
{"shell_command": [{"cmd": "vim"}]},
{"shell_command": [{"cmd": 'cowsay "hey"'}]},
],
"layout": "main-verticle",
},
{
"window_name": "logging",
"start_directory": "~",
"panes": [
{"shell_command": ["tail -F /var/log/syslog"]},
{"shell_command": [{"cmd": "tail -F /var/log/syslog"}]},
{"shell_command": []},
],
},
Expand All @@ -26,14 +29,17 @@
{
"window_name": "editor",
"start_directory": "/var/log",
"panes": [{"shell_command": ["vim"]}, {"shell_command": ['cowsay "hey"']}],
"panes": [
{"shell_command": [{"cmd": "vim"}]},
{"shell_command": [{"cmd": 'cowsay "hey"'}]},
],
"layout": "main-verticle",
},
{
"start_directory": "~",
"window_name": "logging",
"panes": [
{"shell_command": ["tail -F /var/log/syslog"]},
{"shell_command": [{"cmd": "tail -F /var/log/syslog"}]},
{"shell_command": []},
],
},
Expand Down
19 changes: 10 additions & 9 deletions tests/fixtures/workspacebuilder/focus_and_pane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@ windows:
focus: true
panes:
- shell_command:
- cd ~
- cmd: cd ~
- shell_command:
- cd /usr
- cmd: cd /usr
focus: true
- shell_command:
- cd ~
- echo "moo"
- top
- cmd: cd ~
- cmd: echo "moo"
- cmd: top
- window_name: window 2
panes:
- shell_command:
- top
- cmd: top
focus: true
- shell_command:
- echo "hey"
- cmd: echo "hey"
- shell_command:
- echo "moo"
- cmd: echo "moo"
- window_name: window 3
panes:
- shell_command: cd /
- shell_command:
- cmd: cd /
focus: true
- pane
- pane
12 changes: 6 additions & 6 deletions tests/fixtures/workspacebuilder/plugin_bs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ windows:
- window_name: editor
layout: tiled
shell_command_before:
- cd ~/
- cmd: cd ~/
panes:
- shell_command:
- cd /var/log
- ls -al | grep \.log
- echo hello
- echo hello
- echo hello
- cmd: cd /var/log
- cmd: ls -al | grep \.log
- cmd: echo hello
- cmd: echo hello
- cmd: echo hello
Loading