Skip to content

Commit 9813ce2

Browse files
authored
CLI: click -> argparse (#830)
- Remove `click` and `sphinx-click` - Add `sphinx-argparse` - Use [`argparse`](https://docs.python.org/3/library/argparse.html) - Remove completion, for now See also: vcs-python/vcspull#400
2 parents 0a6e23a + afb7af3 commit 9813ce2

28 files changed

+1634
-749
lines changed

CHANGES

+20-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,26 @@ $ pipx install --suffix=@next 'tmuxp' --pip-args '\--pre' --force
1717

1818
## tmuxp 1.17.x (unreleased)
1919

20-
- _Insert changes/features/fixes for next release here_
20+
- Notes on upcoming releases will be added here
21+
22+
<!-- Maintainers, insert changes / features for the next release here -->
23+
24+
### Breaking changes
25+
26+
- **Completions have changed** (#830)
27+
28+
Completions now use a different tool: [shtab]. See the [completions page] for more information.
29+
30+
If you were using earlier versions of tmuxp (earlier than 1.17.0), you may need to uninstall the old completions, first.
31+
32+
[completions page]: https://tmuxp.git-pull.com/cli/completion.html
33+
[shtab]: https://docs.iterative.ai/shtab/
34+
35+
- Deprecate `click` in favor of {mod}`argparse` (#830)
36+
37+
### Packages
38+
39+
- Remove `click` dependency
2140

2241
## tmuxp 1.16.2 (2022-10-08)
2342

MIGRATION

+14-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,20 @@ well.
2121

2222
## Next release
2323

24-
_Add migration notes here_
24+
_Notes on the upcoming release will be added here_
25+
26+
<!-- Maintainers, insert changes / features for the next release here -->
27+
28+
## 1.17.x (unreleased)
29+
30+
**Completions have changed** (#830)
31+
32+
Completions now use a different tool: [shtab]. See the [completions page] for more information.
33+
34+
If you were using earlier versions of tmuxp (earlier than 1.17.0), you may need to uninstall the old completions, first.
35+
36+
[completions page]: https://tmuxp.git-pull.com/cli/completion.html
37+
[shtab]: https://docs.iterative.ai/shtab/
2538

2639
<!---
2740
# vim: set filetype=markdown:

Makefile

+6
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,9 @@ watch_mypy:
5858

5959
format_markdown:
6060
npx prettier --parser=markdown -w *.md docs/*.md docs/**/*.md CHANGES
61+
62+
monkeytype_create:
63+
poetry run monkeytype run `poetry run which py.test`
64+
65+
monkeytype_apply:
66+
poetry run monkeytype list-modules | xargs -n1 -I{} sh -c 'poetry run monkeytype apply {}'

conftest.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
@pytest.mark.skipif(USING_ZSH, reason="Using ZSH")
2727
@pytest.fixture(autouse=USING_ZSH, scope="session")
28-
def zshrc(user_path: pathlib.Path):
28+
def zshrc(user_path: pathlib.Path) -> pathlib.Path:
2929
"""This quiets ZSH default message.
3030
3131
Needs a startup file .zshenv, .zprofile, .zshrc, .zlogin.
@@ -41,7 +41,7 @@ def home_path_default(monkeypatch: pytest.MonkeyPatch, user_path: pathlib.Path)
4141

4242

4343
@pytest.fixture(scope="function")
44-
def monkeypatch_plugin_test_packages(monkeypatch):
44+
def monkeypatch_plugin_test_packages(monkeypatch: pytest.MonkeyPatch) -> None:
4545
paths = [
4646
"tests/fixtures/pluginsystem/plugins/tmuxp_test_plugin_bwb/",
4747
"tests/fixtures/pluginsystem/plugins/tmuxp_test_plugin_bs/",
@@ -55,7 +55,7 @@ def monkeypatch_plugin_test_packages(monkeypatch):
5555

5656

5757
@pytest.fixture(scope="function")
58-
def socket_name(request) -> str:
58+
def socket_name(request: pytest.FixtureRequest) -> str:
5959
return "tmuxp_test%s" % next(namer)
6060

6161

docs/cli/completion.md

+48-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,58 @@
11
(completion)=
22

3-
# Completion
3+
(completions)=
4+
5+
(cli-completions)=
6+
7+
# Completions
8+
9+
## tmuxp 1.17+ (experimental)
10+
11+
```{note}
12+
See the [shtab library's documentation on shell completion](https://docs.iterative.ai/shtab/use/#cli-usage) for the most up to date way of connecting completion for tmuxp.
13+
```
14+
15+
Provisional support for completions in tmuxp 1.17+ are powered by [shtab](https://docs.iterative.ai/shtab/). This must be **installed separately**, as it's **not currently bundled with tmuxp**.
16+
17+
```console
18+
$ pip install shtab --user
19+
```
20+
21+
:::{tab} bash
22+
23+
```bash
24+
shtab --shell=bash -u tmuxp.cli.create_parser \
25+
| sudo tee "$BASH_COMPLETION_COMPAT_DIR"/TMUXP
26+
```
27+
28+
:::
29+
30+
:::{tab} zsh
31+
32+
```zsh
33+
shtab --shell=zsh -u tmuxp.cli.create_parser \
34+
| sudo tee /usr/local/share/zsh/site-functions/_TMUXP
35+
```
36+
37+
:::
38+
39+
:::{tab} tcsh
40+
41+
```zsh
42+
shtab --shell=tcsh -u tmuxp.cli.create_parser \
43+
| sudo tee /etc/profile.d/TMUXP.completion.csh
44+
```
45+
46+
:::
47+
48+
## tmuxp 1.1 to 1.16
449

550
```{note}
651
See the [click library's documentation on shell completion](https://click.palletsprojects.com/en/8.0.x/shell-completion/) for the most up to date way of connecting completion for tmuxp.
752
```
853

54+
tmuxp 1.1 to 1.16 use [click](https://click.palletsprojects.com)'s completion:
55+
956
:::{tab} Bash
1057

1158
_~/.bashrc_:

docs/cli/convert.md

+10-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44

55
Convert between YAML and JSON
66

7+
```{eval-rst}
8+
.. argparse::
9+
:module: tmuxp.cli
10+
:func: create_parser
11+
:prog: tmuxp
12+
:path: convert
13+
```
14+
15+
## Usage
16+
717
````{tab} YAML -> JSON
818
919
```console
@@ -22,12 +32,3 @@ $ tmuxp convert /path/to/file.json
2232

2333
tmuxp automatically will prompt to convert `.yaml` to `.json` and
2434
`.json` to `.yaml`.
25-
26-
## Reference
27-
28-
```{eval-rst}
29-
.. click:: tmuxp.cli.convert:command_convert
30-
:prog: tmuxp convert
31-
:commands: convert
32-
:nested: full
33-
```

docs/cli/debug-info.md

+10-9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
Use to collect all relevant information for submitting an issue to
88
the project.
99

10+
```{eval-rst}
11+
.. argparse::
12+
:module: tmuxp.cli
13+
:func: create_parser
14+
:prog: tmuxp
15+
:path: debug-info
16+
```
17+
18+
## Usage
19+
1020
```console
1121

1222
$ tmuxp debug-info
@@ -17,12 +27,3 @@ environment:
1727
...
1828

1929
```
20-
21-
## Reference
22-
23-
```{eval-rst}
24-
.. click:: tmuxp.cli.debug_info:command_debug_info
25-
:prog: tmuxp debug-info
26-
:commands: debug-info
27-
:nested: full
28-
```

docs/cli/edit.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
(edit-config)=
22

3+
(cli-edit)=
4+
35
# tmuxp edit
46

57
```{eval-rst}
6-
.. click:: tmuxp.cli.edit:command_edit
7-
:prog: tmuxp edit
8-
:commands: edit
9-
:nested: full
8+
.. argparse::
9+
:module: tmuxp.cli
10+
:func: create_parser
11+
:prog: tmuxp
12+
:path: edit
1013
```

docs/cli/freeze.md

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
(cli-freeze)=
22

3+
(cli-freeze-reference)=
4+
35
# tmuxp freeze
46

7+
```{eval-rst}
8+
.. argparse::
9+
:module: tmuxp.cli
10+
:func: create_parser
11+
:prog: tmuxp
12+
:path: freeze
13+
```
14+
15+
## Usage
16+
517
Freeze sessions
618

719
```console
@@ -23,12 +35,3 @@ Tmuxp will offer to save your session state to `.json` or `.yaml`.
2335
If no session is specified, it will default to the attached session.
2436

2537
If the `--force` argument is passed, it will overwrite any existing config file with the same name.
26-
27-
(cli-freeze-reference)=
28-
29-
```{eval-rst}
30-
.. click:: tmuxp.cli.freeze:command_freeze
31-
:prog: tmuxp freeze
32-
:commands: freeze
33-
:nested: full
34-
```

docs/cli/import.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
## From teamocil
88

99
```{eval-rst}
10-
.. click:: tmuxp.cli.import_config:command_import_teamocil
11-
:prog: tmuxp import teamocil
12-
:nested: full
10+
.. argparse::
11+
:module: tmuxp.cli
12+
:func: create_parser
13+
:prog: tmuxp
14+
:path: import teamocil
1315
```
1416

1517
````{tab} YAML
@@ -33,9 +35,11 @@ $ tmuxp import teamocil /path/to/file.json
3335
## From tmuxinator
3436

3537
```{eval-rst}
36-
.. click:: tmuxp.cli.import_config:command_import_tmuxinator
37-
:prog: tmuxp import tmuxinator
38-
:nested: short
38+
.. argparse::
39+
:module: tmuxp.cli
40+
:func: create_parser
41+
:prog: tmuxp
42+
:path: import tmuxinator
3943
```
4044

4145
````{tab} YAML

docs/cli/index.md

+18-3
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,35 @@ edit
2121
import
2222
convert
2323
freeze
24-
2524
```
2625

2726
```{toctree}
2827
:caption: Diagnostic
2928
:maxdepth: 1
3029
3130
debug-info
32-
3331
```
3432

3533
```{toctree}
36-
:caption: More
34+
:caption: Completion
3735
:maxdepth: 1
3836
3937
completion
4038
```
39+
40+
(cli-main)=
41+
42+
(tmuxp-main)=
43+
44+
## Command: `tmuxp`
45+
46+
```{eval-rst}
47+
.. argparse::
48+
:module: tmuxp.cli
49+
:func: create_parser
50+
:prog: tmuxp
51+
:nosubcommands:
52+
53+
subparser_name : @replace
54+
See :ref:`cli-ls`
55+
```

docs/cli/load.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,20 @@
22

33
(tmuxp-load)=
44

5+
(tmuxp-load-reference)=
6+
57
# tmuxp load
68

9+
```{eval-rst}
10+
.. argparse::
11+
:module: tmuxp.cli
12+
:func: create_parser
13+
:prog: tmuxp
14+
:path: load
15+
```
16+
17+
## Usage
18+
719
You can load your tmuxp file and attach the vim session via a few
820
shorthands:
921

@@ -136,14 +148,3 @@ $ tmuxp load [filename] --log-file [log_filename]
136148
```console
137149
$ tmuxp --log-level [LEVEL] load [filename] --log-file [log_filename]
138150
```
139-
140-
## Reference
141-
142-
(tmuxp-load-reference)=
143-
144-
```{eval-rst}
145-
.. click:: tmuxp.cli.load:command_load
146-
:prog: tmuxp load
147-
:commands: load
148-
:nested: full
149-
```

docs/cli/ls.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
(cli-ls)=
2+
13
(ls-config)=
24

35
# tmuxp ls
46

7+
List sesssions.
8+
59
```{eval-rst}
6-
.. click:: tmuxp.cli.ls:command_ls
7-
:prog: tmuxp ls
8-
:commands: ls
9-
:nested: full
10+
.. argparse::
11+
:module: tmuxp.cli
12+
:func: create_parser
13+
:prog: tmuxp
14+
:path: ls
1015
```

0 commit comments

Comments
 (0)