Skip to content

Commit

Permalink
Change hook entry point for better standalone usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja committed Jun 29, 2021
1 parent d9a8e0f commit 9952287
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.5.0
current_version = 1.5.1

[bumpversion:file:setup.cfg]

Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
always_run: true
- id: freenom-autorenew
name: freenom-autorenew
entry: freenom-autorenew-hook
entry: freenom-autorenew
description: Renews the free domains of your Freenom account
language: python
always_run: true
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

```yaml
- repo: https://github.com/mondeja/pre-commit-hooks
rev: v1.5.0
rev: v1.5.1
hooks:
- id: dev-extras-required
- id: root-editorconfig-required
Expand Down Expand Up @@ -118,8 +118,8 @@ The required DNS records to make it pass are:

Renews your free [Freenom][freenom-link] domains.

You must set the environment variables `FREENOM_EMAIL` and `FREENOM_PASSWORD`
to give permissions to this hook for entering in your Freenom account.
> You must set the environment variables `FREENOM_EMAIL` and `FREENOM_PASSWORD`
to give permissions to this hook for entering in your Freenom account.

#### Parameters

Expand All @@ -136,13 +136,16 @@ to give permissions to this hook for entering in your Freenom account.

#### How to use standalone

You can use this hook directly from the command line in an online workflow.
You can use this script directly from the command line in an online workflow.

```bash
pip install mondeja-pre-commit-hooks requests
```

Use the CLI entry `freenom-autorenew-hook`. Example for Github Actions:
Use the CLI entry `freenom-autorenew` to execute it. You can check the
documentation for the script executing `frenom-autorenew -h`.

Configuration example for Github Actions:

```yaml
name: freenom-autorenew
Expand Down
12 changes: 10 additions & 2 deletions hooks/freenom_autorenew.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Script that auto renews a free Freenom domain."""
"""Script that auto renews free Freenom domains."""

import argparse
import functools
Expand Down Expand Up @@ -158,7 +158,15 @@ def autorenew_freenom_domain(domain=None, period="12M", quiet=False):


def main():
parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(
description=(
"Free Freenom domains autorenewer script.\n\nneeded environment"
" variables:\n - 'FREENOM_EMAIL': Email used to authenticate"
" your Freenom account.\n - 'FREENOM_PASSWORD': Password used to"
" authenticate your Freenom account."
),
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument("-q", "--quiet", action="store_true", help="Supress output")
parser.add_argument(
"-d",
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = mondeja_pre_commit_hooks
version = 1.5.0
version = 1.5.1
description = My own useful pre-commit hooks
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down Expand Up @@ -34,7 +34,7 @@ console_scripts =
add-pre-commit-hook = hooks.add_pre_commit_hook:main
cloudflare-gh-pages-dns-hook = hooks.cf_gh_pages_dns_records:main
dev-extras-required-hook = hooks.dev_extras_required:main
freenom-autorenew-hook = hooks.freenom_autorenew:main
freenom-autorenew = hooks.freenom_autorenew:main
nameservers-endswith-hook = hooks.nameservers_endswith:main
root-editorconfig-required-hook = hooks.root_editorconfig_required:main
wavelint-hook = hooks.wavelint:main
Expand Down

0 comments on commit 9952287

Please sign in to comment.