Refactor command line argument parsing and handling for generating calendars

- Added a mutually exclusive group for the `--type` flag to specify the type of calendar to generate: weekly or monthly
- Added two new arguments `--weekly` and `--monthly` to specify the type of calendar directly
- Updated the default value for `--type` to be "weekly"
This commit is contained in:
Kumi 2023-09-30 19:03:55 +02:00
parent 92cdf67db7
commit 541d69ef5d
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -123,13 +123,18 @@ def main():
required=False,
default="%b %d, %Y",
)
parser.add_argument(
type_group = parser.add_mutually_exclusive_group()
type_group.add_argument(
"--type",
"-t",
help="Type of calendar to generate",
required=False,
choices=["weekly", "monthly"],
default="weekly",
)
type_group.add_argument('--monthly', action='store_const', const='monthly', dest='type')
type_group.add_argument('--weekly', action='store_const', const='weekly', dest='type')
count_group = parser.add_mutually_exclusive_group()
count_group.add_argument(