forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release_notes_check_args.py
50 lines (46 loc) · 1.68 KB
/
release_notes_check_args.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
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
import argparse
import datetime
import logging
from typing import IO, List
class ReleaseNotesCheckArgs:
action: str
manifest: List[IO]
date: str
output: str
def __init__(self) -> None:
parser = argparse.ArgumentParser(description="Checkout an OpenSearch Bundle and check for CommitID and Release Notes")
parser.add_argument("action", choices=["check", "compile"], help="Operation to perform.")
parser.add_argument("manifest", type=argparse.FileType("r"), nargs='+', help="Manifest file.")
parser.add_argument(
"-v",
"--verbose",
help="Show more verbose output.",
action="store_const",
default=logging.INFO,
const=logging.DEBUG,
dest="logging_level",
)
parser.add_argument(
"--date",
type=lambda s: datetime.datetime.strptime(s, "%Y-%m-%d").date(),
dest="date",
help="Date to retrieve the commit (in format yyyy-mm-dd, example 2022-07-26)."
)
parser.add_argument(
"--output",
help="Output file."
)
args = parser.parse_args()
self.logging_level = args.logging_level
self.action = args.action
self.manifest = args.manifest
self.date = args.date
self.output = args.output
if self.action == "check" and self.date is None:
parser.error("check option requires --date argument")