From 541d69ef5d703e7abb5fdca2cef4d858e43dd6d5 Mon Sep 17 00:00:00 2001 From: Kumi Date: Sat, 30 Sep 2023 19:03:55 +0200 Subject: [PATCH] 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" --- src/kalente/__main__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/kalente/__main__.py b/src/kalente/__main__.py index b22367d..ab2f76a 100644 --- a/src/kalente/__main__.py +++ b/src/kalente/__main__.py @@ -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(