netcmd: add optparse validators and Range validator
commit1a5184e404d602e389b96535e792fc77314f1fd4
authorRob van der Linde <rob@catalyst.net.nz>
Mon, 15 May 2023 23:47:45 +0000 (16 11:47 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 25 Jun 2023 23:29:32 +0000 (25 23:29 +0000)
treeb8f3b916ffbb1e55ae2197dfb1860bbf2fb2a8df
parent9f5216912e0b2f2d0e74d4dbd10f3fb5017de331
netcmd: add optparse validators and Range validator

Add the ability to the add validators to optparse Option fields.

The Option class was already subclassed in `netcmd/__init__.py` so
adding some functionality to this was relatively easy.

Added the ability to add Validator classes to a field so that this can
be used for anything else in the future, but for now there is a Range
validator required by upcoming auto silo commands.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
python/samba/netcmd/__init__.py
python/samba/netcmd/validators.py [new file with mode: 0644]