# Gerrit Hooks Argument Parsers
This library provides pre-built `argparse.ArgumentParser` instances, which
return `argpase.NameSpace` object for gerrit's hooks (linked in the [Resources](#resources) section below).
It allows developers to get started with gerrit hooks faster, by
getting the parsing of command-line arguments for the various hook types
out of the way.
All hooks are supported.
# Installation
```
pip install gerrit-hooks
```
# Usage
Writing hooks using gerrit-hooks' argparsers is easy:
```python
> gerrit/hooks/comment-added
#!/usr/bin/env/python3
import gerrit_hooks
options = gerrit_hooks.parse_options()
print("Change ID: {}".format(options.change))
...
```
Custom approval categories are supported as well - these must be added
before calling `gerrit_hooks.parse_options()`:
```python
> gerrit/hooks/comment-added
#!/usr/bin/env/python3
import gerrit_hooks
# Let's assume you have a approval category with label 'level-of-amazingness
# We need to add this to the Hook Flag Definitions class
gerrit_hooks.add_custom_approval_category('level-of-amazingness')
options = gerrit_hooks.parse_options()
# The approval category can be accessed by the following attributes:
print("Level of Amazingness is: {}".format(options.level_of_amazingness))
print("Level of Amazingness was: {}".format(options.level_of_amazingness_oldValue))
...
```
# Resources
[Gerrit-Hooks Plugin](https://gerrit-review.googlesource.com/admin/repos/plugins%2Fhooks)
This library provides pre-built `argparse.ArgumentParser` instances, which
return `argpase.NameSpace` object for gerrit's hooks (linked in the [Resources](#resources) section below).
It allows developers to get started with gerrit hooks faster, by
getting the parsing of command-line arguments for the various hook types
out of the way.
All hooks are supported.
# Installation
```
pip install gerrit-hooks
```
# Usage
Writing hooks using gerrit-hooks' argparsers is easy:
```python
> gerrit/hooks/comment-added
#!/usr/bin/env/python3
import gerrit_hooks
options = gerrit_hooks.parse_options()
print("Change ID: {}".format(options.change))
...
```
Custom approval categories are supported as well - these must be added
before calling `gerrit_hooks.parse_options()`:
```python
> gerrit/hooks/comment-added
#!/usr/bin/env/python3
import gerrit_hooks
# Let's assume you have a approval category with label 'level-of-amazingness
# We need to add this to the Hook Flag Definitions class
gerrit_hooks.add_custom_approval_category('level-of-amazingness')
options = gerrit_hooks.parse_options()
# The approval category can be accessed by the following attributes:
print("Level of Amazingness is: {}".format(options.level_of_amazingness))
print("Level of Amazingness was: {}".format(options.level_of_amazingness_oldValue))
...
```
# Resources
[Gerrit-Hooks Plugin](https://gerrit-review.googlesource.com/admin/repos/plugins%2Fhooks)
Release files for gerrit-hooks 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gerrit_hooks-2.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / gerrit_hooks-2.0.0-py3-none-any.whl
| Download URL | gerrit_hooks-2.0.0-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ded61ad23b25b7bcd19c17e28f49749d96ae05576767d4115cf344492a05a63a
|
|
BLAKE2b-256 checksum How to use checksums |
491426c7da8018faa7aefd9ad5f325fe684e818cc17bb046a958e09d6bddcc72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.2
|