mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-18 16:31:26 -07:00
[PR #5647/be22ca06 backport][stable-6] cmd_runner: allow bool format to pass alternate (false) value (#5650)
cmd_runner: allow bool format to pass alternate (false) value (#5647)
* allow bool format to pass alternate (false) value
* add changelog fragment
(cherry picked from commit be22ca0633
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
2d616bf4d1
commit
cc28cde3a2
3 changed files with 13 additions and 2 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue