Skip to content

Commit

Permalink
exposed functions, added example, cleaned up readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsadler-branch committed Sep 4, 2022
1 parent 99e83b0 commit b55753d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 13 deletions.
39 changes: 34 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
# github_api
Python Script for interacting with Github API.

---

## Example Comment:
```text
https://github.com/org-not-included/py-github-helper/pull/2#issuecomment-1236262158
```

---

## Example Code Usage:
```text
from py_github_helper.utils.commands import add_comment
## Example
add_comment(
organization="org-not-included",
repository="py-github-helper",
pull_request_id="2",
message="This is an automated message via Github API",
token="my_github_token",
username="my_github_handle",
password=None,
)
```

---

## Example CLI Usage:
```shell
python3 -m py-github-helper \
-t $GH_TOKEN -o org-not-included -r sample-repo -l 1 -c add_comment \
-e '{"message": "This message was successfully posted via gitub_api."}'
```

---

## Quick start
1. Create a new [Github repo](https://github.com/new).
2. Create a local folder and push it to the new repository:
Expand Down Expand Up @@ -45,15 +73,16 @@ python3 -m py-github-helper \
-e '{"message": "This message was successfully posted via gitub_api."}'
```
![Comment on PR](img/pr_comment.png)

---

## Docs
```shell
python3 -m py-github-helper --help
```



---

```text
usage: python3 -m py-github-helper [-h] [-o ORGANIZATION] [-r REPOSITORY] [-t TOKEN] [-u USERNAME] [-p PASSWORD] [-l PULL_REQUEST_ID] [-c COMMAND] [-e EXTRAS]
Expand Down
7 changes: 7 additions & 0 deletions py-github-helper/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .utils import commands
import utils

__all__ = [
commands,
utils,
]
7 changes: 1 addition & 6 deletions py-github-helper/__main__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import logging
import sys
from .utils.custom_arg_parser import parse_args


def main(argv):
return parse_args(argv)


if __name__ == "__main__":
logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.ERROR)
print(main(sys.argv[1:]))
print(parse_args())
exit(0)
2 changes: 1 addition & 1 deletion py-github-helper/utils/custom_arg_parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .commands import *


def parse_args(argv):
def parse_args():
"""
Parses input arguments and formats parameters for generating specified command (API request).
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path


VERSION = '0.1.14'
VERSION = '0.2.0'
DESCRIPTION = 'Python Script for interacting with Github API'
this_directory = Path(__file__).parent
long_description = (this_directory / "README.md").read_text()
Expand Down

0 comments on commit b55753d

Please sign in to comment.