Skip to content

Commit 972de27

Browse files
Document CLI
1 parent 63f8e15 commit 972de27

File tree

4 files changed

+189
-53
lines changed

4 files changed

+189
-53
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ uv tool install upgrade-dependencies
1414
You can then navigate to your project directory and execute:
1515

1616
```
17-
uvx upgrade-dependencies [OPTIONS] [COMMAND]
17+
uvx upgrade-dependencies [OPTIONS] COMMAND [ARGS]...
1818
```
1919

20+
See the [CLI documentation](docs/usage.md) for information about how each command works.
21+
2022
### Requirements
2123

2224
All python requirements are installed by default. To successfully use the `update`

docs/usage.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# `upgrade-dependencies`
2+
3+
**Usage**:
4+
5+
```console
6+
$ upgrade-dependencies [OPTIONS] COMMAND [ARGS]...
7+
```
8+
9+
**Options**:
10+
11+
* `--install-completion`: Install completion for the current shell.
12+
* `--show-completion`: Show completion for the current shell, to copy it or customize the installation.
13+
* `--help`: Show this message and exit.
14+
15+
**Commands**:
16+
17+
* `list-dependencies`: List all the dependencies for the project.
18+
* `check-dependency`: Checks whether a dependency needs updating.
19+
* `needs-updating`: Lists the dependencies that need updating.
20+
* `latest-versions`: List the dependencies that aren't specified to the latest version.
21+
* `update`: Updates a dependency to a specific (or latest) version.
22+
* `format-yml`: Formats the workflow and pre-commit config yaml files.
23+
24+
## `upgrade-dependencies list-dependencies`
25+
26+
List all the dependencies for the project.
27+
28+
**Usage**:
29+
30+
```console
31+
$ upgrade-dependencies list-dependencies [OPTIONS]
32+
```
33+
34+
**Options**:
35+
36+
* `--help`: Show this message and exit.
37+
38+
## `upgrade-dependencies check-dependency`
39+
40+
Checks whether a dependency needs updating.
41+
42+
**Usage**:
43+
44+
```console
45+
$ upgrade-dependencies check-dependency [OPTIONS] DEPENDENCY
46+
```
47+
48+
**Arguments**:
49+
50+
* `DEPENDENCY`: Name of the dependency to check [required]
51+
52+
**Options**:
53+
54+
* `--help`: Show this message and exit.
55+
56+
## `upgrade-dependencies needs-updating`
57+
58+
Lists the dependencies that need updating.
59+
60+
**Usage**:
61+
62+
```console
63+
$ upgrade-dependencies needs-updating [OPTIONS]
64+
```
65+
66+
**Options**:
67+
68+
* `--base / --no-base`: Include base dependencies [default: base]
69+
* `--optional-deps / --no-optional-deps`: Include optional dependencies [default: optional-deps]
70+
* `--group-deps / --no-group-deps`: Include dependency groups [default: group-deps]
71+
* `--github-actions / --no-github-actions`: Include GitHub actions dependencies [default: github-actions]
72+
* `--pre-commit / --no-pre-commit`: Include pre-commit dependencies [default: pre-commit]
73+
* `--help`: Show this message and exit.
74+
75+
## `upgrade-dependencies latest-versions`
76+
77+
List the dependencies that aren't specified to the latest version.
78+
79+
**Usage**:
80+
81+
```console
82+
$ upgrade-dependencies latest-versions [OPTIONS]
83+
```
84+
85+
**Options**:
86+
87+
* `--base / --no-base`: Include base dependencies [default: base]
88+
* `--optional-deps / --no-optional-deps`: Include optional dependencies [default: optional-deps]
89+
* `--group-deps / --no-group-deps`: Include dependency groups [default: group-deps]
90+
* `--github-actions / --no-github-actions`: Include GitHub actions dependencies [default: no-github-actions]
91+
* `--pre-commit / --no-pre-commit`: Include pre-commit dependencies [default: pre-commit]
92+
* `--help`: Show this message and exit.
93+
94+
## `upgrade-dependencies update`
95+
96+
Updates a dependency to a specific (or latest) version.
97+
98+
Makes changes to the dependency specification locally and creates a GitHub pull
99+
request on a new branch (branch name = dependency/{package_name}-{version}). Make
100+
sure this branch name does not exist locally or on GitHub.
101+
102+
Requires git and the GitHub CLI to be installed. It is recommended to have a clean
103+
git before running this command.
104+
105+
**Usage**:
106+
107+
```console
108+
$ upgrade-dependencies update [OPTIONS] DEPENDENCY
109+
```
110+
111+
**Arguments**:
112+
113+
* `DEPENDENCY`: Dependency to update [required]
114+
115+
**Options**:
116+
117+
* `--version TEXT`: Version to update to, latest version if not specified
118+
* `--target-branch TEXT`: Name of the branch to merge PR to [default: master]
119+
* `--help`: Show this message and exit.
120+
121+
## `upgrade-dependencies format-yml`
122+
123+
Formats the workflow and pre-commit config yaml files.
124+
125+
**Usage**:
126+
127+
```console
128+
$ upgrade-dependencies format-yml [OPTIONS]
129+
```
130+
131+
**Options**:
132+
133+
* `--help`: Show this message and exit.

src/upgrade_dependencies/main.py

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

33
import asyncio
44
import os
5-
from typing import TYPE_CHECKING
5+
from typing import TYPE_CHECKING, Annotated
66

77
import typer
88
from packaging.version import Version
@@ -25,7 +25,7 @@
2525

2626
@app.command()
2727
def list_dependencies():
28-
"""Checks whether a dependency needs updating."""
28+
"""List all the dependencies for the project."""
2929
project = Project(gh_pat=GH_PAT)
3030

3131
# base dependencies
@@ -119,12 +119,10 @@ def list_dependencies():
119119

120120

121121
@app.command()
122-
def check_dependency(dependency: str):
123-
"""Checks whether a dependency needs updating.
124-
125-
Args:
126-
dependency: Name of the dependency to check.
127-
"""
122+
def check_dependency(
123+
dependency: Annotated[str, typer.Argument(help="Name of the dependency to check")],
124+
):
125+
"""Checks whether a dependency needs updating."""
128126
project = Project(gh_pat=GH_PAT)
129127

130128
try:
@@ -156,24 +154,22 @@ def check_dependency(dependency: str):
156154

157155
@app.command()
158156
def needs_updating(
159-
base: bool = True,
160-
optional_deps: bool = True,
161-
group_deps: bool = True,
162-
github_actions: bool = True,
163-
pre_commit: bool = True,
157+
base: Annotated[bool, typer.Option(help="Include base dependencies")] = True,
158+
optional_deps: Annotated[
159+
bool,
160+
typer.Option(help="Include optional dependencies"),
161+
] = True,
162+
group_deps: Annotated[bool, typer.Option(help="Include dependency groups")] = True,
163+
github_actions: Annotated[
164+
bool,
165+
typer.Option(help="Include GitHub actions dependencies"),
166+
] = True,
167+
pre_commit: Annotated[
168+
bool,
169+
typer.Option(help="Include pre-commit dependencies"),
170+
] = True,
164171
):
165-
"""List the dependencies that need updating.
166-
167-
Args:
168-
base: If set to True, includes the base dependencies. Defaults to True.
169-
optional_deps: If set to True, includes the optional dependencies. Defaults to
170-
True.
171-
group_deps: If set to True, includes the dependency groups. Defaults to True.
172-
github_actions: If set to True, includes the github actions dependencies.
173-
Defaults to True.
174-
pre_commit: If set to True, includes the pre-commit dependencies. Defaults to
175-
True.
176-
"""
172+
"""Lists the dependencies that need updating."""
177173
# create project object
178174
project = Project(gh_pat=GH_PAT)
179175

@@ -225,24 +221,22 @@ def needs_updating(
225221

226222
@app.command()
227223
def latest_versions(
228-
base: bool = True,
229-
optional_deps: bool = True,
230-
group_deps: bool = True,
231-
github_actions: bool = False,
232-
pre_commit: bool = True,
224+
base: Annotated[bool, typer.Option(help="Include base dependencies")] = True,
225+
optional_deps: Annotated[
226+
bool,
227+
typer.Option(help="Include optional dependencies"),
228+
] = True,
229+
group_deps: Annotated[bool, typer.Option(help="Include dependency groups")] = True,
230+
github_actions: Annotated[
231+
bool,
232+
typer.Option(help="Include GitHub actions dependencies"),
233+
] = False,
234+
pre_commit: Annotated[
235+
bool,
236+
typer.Option(help="Include pre-commit dependencies"),
237+
] = True,
233238
):
234-
"""List the dependencies that aren't pinned to the latest version.
235-
236-
Args:
237-
base: If set to True, includes the base dependencies. Defaults to True.
238-
optional_deps: If set to True, includes the optional dependencies. Defaults to
239-
True.
240-
group_deps: If set to True, includes the dependency groups. Defaults to True.
241-
github_actions: If set to True, includes the github actions dependencies.
242-
Defaults to False.
243-
pre_commit: If set to True, includes the pre-commit dependencies. Defaults to
244-
True.
245-
"""
239+
"""List the dependencies that aren't specified to the latest version."""
246240
# create project object
247241
project = Project(gh_pat=GH_PAT)
248242

@@ -294,18 +288,24 @@ def latest_versions(
294288

295289
@app.command()
296290
def update(
297-
dependency: str,
298-
version: str | None = None,
299-
target_branch: str = "master",
291+
dependency: Annotated[str, typer.Argument(help="Dependency to update")],
292+
version: Annotated[
293+
str | None,
294+
typer.Option(help="Version to update to, latest version if not specified"),
295+
] = None,
296+
target_branch: Annotated[
297+
str,
298+
typer.Option(help="Name of the branch to merge PR to"),
299+
] = "master",
300300
):
301-
"""_summary_.
301+
"""Updates a dependency to a specific (or latest) version.
302302
303-
Make sure branch locally and on github do not already exist!
303+
Makes changes to the dependency specification locally and creates a GitHub pull
304+
request on a new branch (branch name = dependency/{package_name}-{version}). Make
305+
sure this branch name does not exist locally or on GitHub.
304306
305-
Args:
306-
dependency: _description_
307-
version: _description_
308-
target_branch: _description_
307+
Requires git and the GitHub CLI to be installed. It is recommended to have a clean
308+
git before running this command.
309309
"""
310310
with Progress(
311311
SpinnerColumn(),

todo.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
- [x] Create changes to files
1212
- [x] Create pull request
1313
- [x] Add format yml files
14-
- [ ] Documentation
14+
- [x] Documentation
15+
- [ ] Add release command
1516
- [ ] Handle uv better (not group)
1617
- [ ] Handle pre-commit yml extension (not yaml)
1718
- [ ] Add tests

0 commit comments

Comments
 (0)