Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
Add config file
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Jan 21, 2024
1 parent c1bebc6 commit 5335266
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 19 deletions.
1 change: 1 addition & 0 deletions .config/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ notest
pycontribs
pypa
setuptools
typer
3 changes: 3 additions & 0 deletions .config/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
pyyaml
rich
typer-config
typing-extensions
1 change: 1 addition & 0 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
with:
min_python: "3.10"
max_python: "3.12"
default_python: "3.10"
other_names: |
lint
pkg
Expand Down
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ repos:
additional_dependencies:
- pytest
- rich
- typer-config
- repo: https://github.com/pycqa/pylint
rev: v3.0.3
hooks:
Expand All @@ -89,6 +90,7 @@ repos:
additional_dependencies:
- pytest
- rich
- typer-config
- repo: https://github.com/jazzband/pip-tools
rev: 7.3.0
hooks:
Expand Down
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,25 @@ gh extension install pycontribs/gh-pre

Usage:

```
```shell
gh pre
```

It can also be installed and executed as a python module:
It can also be installed and executed as a Python package:

```
```shell
pip install gh-pre
pre
```

## Configuration

Please create a `~/pre.yml` config file with content similar to:

```
repos:
- github-org/project1
- github-org/project2
```

This will tell it which repositories to check for draft releases.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ classifiers = [
keywords = ["gh", "github"]

[project.scripts]
pre = "gh_pre.__main__:main"
pre = "gh_pre.__main__:app"

[project.urls]
homepage = "https://github.com/pycontribs/gh-pre"
Expand Down
27 changes: 13 additions & 14 deletions src/gh_pre/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,26 @@

import datetime
from subprocess import run
import os

from rich.panel import Panel
from rich import box
from rich.console import Console
import typer
from typer_config.callbacks import argument_list_callback
from typer_config.decorators import use_yaml_config


def main() -> None:
app = typer.Typer()


@app.command()
@use_yaml_config(default_value=os.path.expanduser("~/pre.yml"))
def main(
repos: list[str] = typer.Argument(default=None, callback=argument_list_callback)
) -> None:
"""Main entrypoint."""
console = Console()
repos = [
"ansible/ansible-compat",
"ansible/ansible-lint",
"ansible/ansible-navigator",
"ansible/ansible-creator",
"ansible/molecule",
"ansible/tox-ansible",
"ansible/pytest-ansible",
"ansible/ansible-development-environment",
"ansible/ansible-dev-tools",
"ansible/creator-ee",
]
for repo in repos:
repo_link = f"[markdown.link][link=https://github.com/{repo}]{repo}[/][/]"
result = run(
Expand Down Expand Up @@ -61,4 +60,4 @@ def main() -> None:

if __name__ == "__main__":
# execute only if run as a script
main()
app()
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ commands =
# Testing gh calling
sh -c "gh extension remove gh-pre || true"
gh extension install .
gh pre --version
gh pre --help

0 comments on commit 5335266

Please sign in to comment.