diff options
author | Jose M. Guisado <jguisado@soleta.eu> | 2023-10-19 13:36:00 +0200 |
---|---|---|
committer | Jose M. Guisado <jguisado@soleta.eu> | 2023-10-19 13:36:00 +0200 |
commit | 37c4065f06f7cdaa35a49c7a6168f50394b37565 (patch) | |
tree | de4d0654d54cb12ea40fe0d689720f50fc2d2a37 | |
parent | 1c2e5c4c96f3c8b114508de7f713dda8ebfcb877 (diff) |
cli: objects: use --desc and --folder
Try to reduce the usage of different parameter names due to the
OpenGnsys database using different column names for similar purposes.
Any database field regarding a description of some sort will use the
parameter --desc, even if the DB uses another column name (for example,
comment column in center table).
Use --folder parameter when requiring a folder id. The database uses
"grupo" as table name but present this to the user as folder, so use
--folder instead of --group.
Also, add 'location' field in the payload of "add room" command, it was
missing the addition of 'location' field in the JSON payload.
-rw-r--r-- | cli/objects/center.py | 6 | ||||
-rw-r--r-- | cli/objects/room.py | 14 |
2 files changed, 11 insertions, 9 deletions
diff --git a/cli/objects/center.py b/cli/objects/center.py index 1869efd..2e851d3 100644 --- a/cli/objects/center.py +++ b/cli/objects/center.py @@ -8,14 +8,14 @@ class OgCenter(): nargs='?', required=True, help='Name of the center') - parser.add_argument('--comment', + parser.add_argument('--desc', nargs='?', required=False, help='(Optional) Provide a more detailed description of the center') parsed_args = parser.parse_args(args) payload = {'name': parsed_args.name} - if parsed_args.comment: - payload['comment'] = parsed_args.comment + if parsed_args.desc: + payload['comment'] = parsed_args.desc rest.post('/center/add', payload=payload) @staticmethod diff --git a/cli/objects/room.py b/cli/objects/room.py index 66d0dba..e6b5445 100644 --- a/cli/objects/room.py +++ b/cli/objects/room.py @@ -20,10 +20,10 @@ class OgRoom(): type=int, required=True, help='provide the id of the center that will contain the room') - parser.add_argument('--location', + parser.add_argument('--desc', nargs='?', required=False, - help='specify the location of the room') + help='room description') parser.add_argument('--gateway', nargs='?', required=True, @@ -36,11 +36,11 @@ class OgRoom(): nargs='?', required=False, help='address of the dns server') - parser.add_argument('--group', + parser.add_argument('--folder', nargs='?', type=int, required=False, - help='id of the group that will contain the room') + help='id of the folder that will contain the room') parsed_args = parser.parse_args(args) err = False @@ -71,8 +71,10 @@ class OgRoom(): payload['ntp'] = parsed_args.ntp if parsed_args.dns: payload['dns'] = parsed_args.dns - if parsed_args.group: - payload['group'] = parsed_args.group + if parsed_args.folder: + payload['group'] = parsed_args.folder + if parsed_args.desc: + payload['location'] = parsed_args.desc rest.post('/room/add', payload=payload) @staticmethod |