From b68b70a097fd9b968407f253c8eaf91c76ff0fd1 Mon Sep 17 00:00:00 2001 From: Nicolas Bock Date: Fri, 25 Sep 2020 08:49:13 -0600 Subject: Add choices to `--type` command line argument We only allow `PRIMARY` and `SECONDARY` zones. Instead of testing for either one of those two choices later in the code, we can offload this test to the parser. Change-Id: I8244e13303646e6686e4233e1edbd2bbc788e054 Signed-off-by: Nicolas Bock --- designateclient/v2/cli/zones.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/designateclient/v2/cli/zones.py b/designateclient/v2/cli/zones.py index d54154b..f740504 100644 --- a/designateclient/v2/cli/zones.py +++ b/designateclient/v2/cli/zones.py @@ -55,7 +55,10 @@ class ListZonesCommand(command.Lister): parser.add_argument('--name', help="Zone Name", required=False) parser.add_argument('--email', help="Zone Email", required=False) - parser.add_argument('--type', help="Zone Type", required=False) + parser.add_argument('--type', help="Zone Type", + choices=["PRIMARY", "SECONDARY"], + default="PRIMARY", + required=False) parser.add_argument('--ttl', help="Time To Live (Seconds)", required=False) parser.add_argument('--description', help="Description", @@ -129,7 +132,9 @@ class CreateZoneCommand(command.ShowOne): parser.add_argument('name', help="Zone Name") parser.add_argument('--email', help="Zone Email") - parser.add_argument('--type', help="Zone Type", default='PRIMARY') + parser.add_argument('--type', help="Zone Type", + choices=["PRIMARY", "SECONDARY"], + default='PRIMARY') parser.add_argument('--ttl', type=int, help="Time To Live (Seconds)") parser.add_argument('--description', help="Description") parser.add_argument('--masters', help="Zone Masters", nargs='+') -- cgit v1.2.1