Skip to content

Commit

Permalink
Redundant DefaultIfBool handling can now be removed
Browse files Browse the repository at this point in the history
    * Test globals affecting triggering the need for this have been resolved
  • Loading branch information
inno committed May 26, 2024
1 parent e067834 commit a14d0c5
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions simplecli/simplecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,21 +328,15 @@ def params_to_kwargs(
missing_params = []
try:
for param in params:
kw_value = kw_args.get(param.name)
# Positional arguments take precedence
if pos_args:
param.set_value(pos_args.pop(0))
elif param.name in kw_args:
if kw_args[param.name] is DefaultIfBool:
# Invert the default value
param.set_value(
True if param.default is Empty else not param.default
)
continue
param.set_value(kw_args[param.name])
elif kw_value:
param.set_value(kw_value)
continue
elif param.required:
missing_params.append(param)
continue
except ValueError as e:
exit(e.args[0])

Expand Down

0 comments on commit a14d0c5

Please sign in to comment.