Skip to content

Commit dbcc2a4

Browse files
SAnCherepanSAnCherepan
authored andcommitted
Moved cli into package
1 parent 2328a6a commit dbcc2a4

5 files changed

Lines changed: 41 additions & 30 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Repo reader
22

3-
This is a simple example package that can be used to get basic info on GitHub repository groups (a.k.a. orgs).
3+
This is a simple example package that can be used to get basic info on GitHub repository groups (a.k.a. organisations).
44

55
# Installation
66

77
Install the python package:
88
```
9-
python -m pip install --index-url https://test.pypi.org/simple/ --no-deps repo_reader_sancherepan
9+
python -m pip install --index-url https://test.pypi.org/simple/ repo_reader_sancherepan
1010
```
1111

1212

@@ -20,4 +20,7 @@ reader = RepoReader("<your_github_auth_token>")
2020
repos = reader.read_repos("<github_repo_group_name>")
2121
```
2222

23-
See also an [example using CLI](cli/print-repos-info.py)
23+
In command line:
24+
```commandline
25+
read-repos your_github_auth_token github_repo_group_name
26+
```

cli/print-repos-info.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "repo_reader_sancherepan"
7-
version = "0.1.1"
7+
version = "0.2.0"
88
authors = [
99
{ name="SAnCherepan", email="sivkinpunk@gmail.com" },
1010
]
@@ -20,4 +20,7 @@ classifiers = [
2020
]
2121

2222
[project.urls]
23-
"Homepage" = "https://github.com/sancherepan/test-code"
23+
"Homepage" = "https://github.com/sancherepan/test-code"
24+
25+
[project.scripts]
26+
read-repos = "repo_reader_sancherepan.print_repos_info:main"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import sys
2+
import argparse
3+
from .repo_reader import RepoReader
4+
5+
6+
def main(args=None):
7+
parser = argparse.ArgumentParser()
8+
parser.add_argument('auth_token', help='<your_github_auth_token>')
9+
parser.add_argument('org_name', help="<github_repo_group_name>")
10+
11+
if args is None:
12+
args = sys.argv[1:]
13+
14+
args = parser.parse_args(args)
15+
auth_token = args.auth_token
16+
org_name = args.org_name
17+
18+
reader = RepoReader(auth_token)
19+
repos = reader.read_repos(org_name)
20+
21+
for repo in repos:
22+
print(f"repo: {repo.name}, "
23+
f"size: {repo.size}, "
24+
f"open_issues: {repo.open_issues_count}, "
25+
f"branches: {len(repo.branches)}\n")
26+
27+
28+
if __name__ == '__main__':
29+
sys.exit(main(sys.argv))

src/repo_reader_sancherepan/repo_reader.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ def __init__(self, auth_token):
1515

1616
def read_repos(self, org_name: str):
1717
url = self.github_base_url + self.github_org_repos_url.format(org_name)
18-
print(f"url: {url}")
19-
18+
2019
response = self.session.get(url)
2120
response.raise_for_status()
2221

0 commit comments

Comments
 (0)