Skip to content

Commit cfffcf2

Browse files
committed
Empty console inputs for simple fields are now converted to the default field values
1 parent 043046e commit cfffcf2

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/murfey/cli/create_config.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,17 @@ def populate_field(key: str, field: ModelField, debug: bool = False) -> Any:
401401

402402
# Display information on the field to be filled
403403
print_field_info(field)
404-
message = "Please provide a value (press Enter to leave it blank as '')."
404+
405+
message = (
406+
"Please provide a value (press Enter to use the default value of "
407+
f"{field.field_info.default!r})."
408+
)
405409
while True:
406410
# Get value
407411
answer = prompt(message, style="bright_yellow")
408-
# Translate empty string into None for fields that take Path values
409-
value = (
410-
None
411-
if (not answer and machine_config_types.get(key) in (Path, Optional[Path]))
412-
else answer
413-
)
412+
413+
# Convert empty console input into default values
414+
value = field.field_info.default if not answer else answer
414415

415416
# Validate and return
416417
try:
@@ -449,7 +450,7 @@ def add_calibrations(
449450
# Check if it's a known type of calibration
450451
if calibration_type not in known_calibrations.keys():
451452
console.print(
452-
f"{calibration_type} is not a known type of calibration",
453+
f"{calibration_type!r} is not a known type of calibration",
453454
style="bright_red",
454455
)
455456
add_calibration = ask_for_input(category, True)

0 commit comments

Comments
 (0)