Skip to content

Commit fac6436

Browse files
committed
Better checks for default values
1 parent c93558d commit fac6436

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

easybuild/cli/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,15 @@ def eb(ctx, other_args):
3737
if value:
3838
args.append(f"--{key}")
3939
else:
40+
if isinstance(value, (list, tuple)) and value:
41+
# Flatten nested lists if necessary
42+
if isinstance(value[0], list):
43+
value = sum(value, [])
44+
# Match the type of the option with the default to see if we need to add it
45+
if isinstance(value, list) and isinstance(opt.default, tuple):
46+
value = tuple(value)
4047
if value and value != opt.default:
41-
if isinstance(value, (list, tuple)) and value:
42-
if isinstance(value[0], list):
43-
value = sum(value, [])
48+
if isinstance(value, (list, tuple)):
4449
if 'path' in opt.type:
4550
delim = os.pathsep
4651
elif 'str' in opt.type:
@@ -50,7 +55,8 @@ def eb(ctx, other_args):
5055
else:
5156
raise ValueError(f"Unsupported type for {key}: {opt.type}")
5257
value = delim.join(value)
53-
print(f"--Adding {key}={value} to args")
58+
59+
# print(f"--Adding {key}={value} to args")
5460
args.append(f"--{key}={value}")
5561

5662
args.extend(other_args)

0 commit comments

Comments
 (0)