-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelpers.py
69 lines (62 loc) · 1.85 KB
/
helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import argparse
import os
import logging
def get_logger():
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
return logging.getLogger(__name__)
def parse_arguments():
parser = argparse.ArgumentParser(
description="GHAS activation and coverage activation"
)
parser.add_argument(
"--ac-report",
type=str,
help="Path to the active committers report",
required=False,
)
parser.add_argument(
"--enterprise", type=str, help="Name of the enterprise", required=False
)
parser.add_argument(
"--organization", type=str, help="Name of the organization", required=False
)
parser.add_argument(
"--output",
type=str,
help="Path to the output file (default: 'report.md')",
required=False,
default="report.md",
)
parser.add_argument(
"--output-format",
type=str,
help="Output format - text or json (default: 'text')",
required=False,
default="text",
)
parser.add_argument(
"--token",
type=str,
help="GitHub Personal Access Token (if not set in GITHUB_TOKEN environment variable)",
required=False,
)
parser.add_argument(
"--licenses",
type=int,
help="Number of (still) available GHAS licenses (default: 0)",
required=False,
default=0,
)
args = parser.parse_args()
if args.enterprise is None and args.organization is None:
parser.error("Either --enterprise or --organization must be provided.")
token = os.getenv("GITHUB_TOKEN") or args.token
if token is None:
parser.error(
"Either GITHUB_TOKEN environment variable or --token must be provided."
)
return args, token