diff options
author | Jens Harbott <j.harbott@x-ion.de> | 2017-12-06 09:32:29 +0000 |
---|---|---|
committer | Jens Harbott <j.harbott@x-ion.de> | 2017-12-07 14:18:31 +0000 |
commit | 66e4955408eacb4859cfef01a31d013e34c28ffb (patch) | |
tree | ea29d0a75c5b24a59bdd55ed210cd25f3871afae /designateclient | |
parent | 31580693224e1b89b58b61ff8fde1b6569fdca79 (diff) | |
download | python-designateclient-66e4955408eacb4859cfef01a31d013e34c28ffb.tar.gz |
Improve recordset create UI
The current implementation has '--records' as a quasi-positional
argument, with the nargs='+' parameter it can only be used at the end of
the command, which is confusing to users and doesn't comply with the
help message.
Add a new option '--record' that takes only exactly one record as
parameter and can be repeated when multiple records are present.
Deprecate the old option so it can be removed in the future.
Change-Id: I8fefd9d0f104170d50c5d5dc3cbcc53facda9baf
Closes-Bug: 1736161
Diffstat (limited to 'designateclient')
-rw-r--r-- | designateclient/v2/cli/recordsets.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/designateclient/v2/cli/recordsets.py b/designateclient/v2/cli/recordsets.py index 9abe611..898da19 100644 --- a/designateclient/v2/cli/recordsets.py +++ b/designateclient/v2/cli/recordsets.py @@ -14,6 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. +import argparse import logging from osc_lib.command import command @@ -140,13 +141,22 @@ class ShowRecordSetCommand(command.ShowOne): class CreateRecordSetCommand(command.ShowOne): """Create new recordset""" + log = logging.getLogger('deprecated') + def get_parser(self, prog_name): parser = super(CreateRecordSetCommand, self).get_parser(prog_name) parser.add_argument('zone_id', help="Zone ID") parser.add_argument('name', help="RecordSet Name") - parser.add_argument('--records', help="RecordSet Records", - nargs='+', required=True) + req_group = parser.add_mutually_exclusive_group(required=True) + req_group.add_argument( + '--records', + help=argparse.SUPPRESS, + nargs='+') + req_group.add_argument( + '--record', + help="RecordSet Record, repeat if necessary", + action='append') parser.add_argument('--type', help="RecordSet Type", required=True) parser.add_argument('--ttl', type=int, help="Time To Live (Seconds)") parser.add_argument('--description', help="Description") @@ -159,11 +169,15 @@ class CreateRecordSetCommand(command.ShowOne): client = self.app.client_manager.dns common.set_all_common_headers(client, parsed_args) + all_records = parsed_args.record or parsed_args.records + if parsed_args.records: + self.log.warning( + "Option --records is deprecated, use --record instead.") data = client.recordsets.create( parsed_args.zone_id, parsed_args.name, parsed_args.type, - parsed_args.records, + all_records, description=parsed_args.description, ttl=parsed_args.ttl) |