cmd_runner: allow bool format to pass alternate (false) value (#5647)

* allow bool format to pass alternate (false) value

* add changelog fragment
This commit is contained in:
Alexei Znamensky 2022-12-05 00:18:33 +13:00 committed by GitHub
parent 23aacc78e1
commit be22ca0633
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View file

@ -103,8 +103,13 @@ class _ArgFormat(object):
class _Format(object):
@staticmethod
def as_bool(args):
return _ArgFormat(lambda value: _ensure_list(args) if value else [])
def as_bool(args_true, args_false=None, ignore_none=None):
if args_false is not None:
if ignore_none is None:
ignore_none = False
else:
args_false = []
return _ArgFormat(lambda value: _ensure_list(args_true) if value else _ensure_list(args_false), ignore_none=ignore_none)
@staticmethod
def as_bool_not(args):