Skip to content

Commit b9b82c0

Browse files
authored
Document how to register pyodide CLI subcommands (#16)
1 parent 9c392a6 commit b9b82c0

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ concurrency:
1111

1212
jobs:
1313
test:
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-20.04
1515
steps:
1616
- uses: actions/checkout@v2
1717
- uses: actions/setup-python@v3
@@ -27,7 +27,7 @@ jobs:
2727
run: |
2828
python -m pytest
2929
deploy:
30-
runs-on: ubuntu-latest
30+
runs-on: ubuntu-20.04
3131
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
3232
environment: PyPi-deploy
3333
steps:

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,5 @@ repos:
6262
hooks:
6363
- id: codespell
6464
args: ["-L", "te,slowy,aray,ba,nd,classs,crate,feld,lits"]
65+
ci:
66+
autoupdate_schedule: "quarterly"

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,32 @@ To get a list of available CLI commands,
2222
pyodide --help
2323
```
2424

25+
## Developers
26+
27+
You can register a subcommand in the `pyodide` CLI in your own package by:
28+
29+
1. adding a dependency on `pyodide-cli`
30+
2. Adding a `pyodide.cli` [entry point](https://setuptools.pypa.io/en/latest/userguide/entry_point.html). For example, with
31+
32+
**setup.cfg**
33+
```toml
34+
[options.entry_points]
35+
pyodide.cli =
36+
do_something = "<your-package>.cli:main"
37+
```
38+
39+
or
40+
41+
**pyproject.toml**
42+
```toml
43+
[project.entry-points."pyodide.cli"]
44+
do_something = "<your-package>.cli:main"
45+
```
46+
47+
where in this example `main` needs to be a function with type annotations
48+
that can be converted to a CLI with [typer](https://typer.tiangolo.com/).
49+
50+
2551
## License
2652

2753
pyodide-cli uses the [Mozilla Public License Version

0 commit comments

Comments
 (0)