- device_string = string_map_find_and_delete (options, "device");
- if (device_string == NULL || device_string[0] == '\0')
- device_type = default_device_type (file_name);
- else if (!strcmp (device_string, "terminal"))
- device_type = SETTINGS_DEVICE_TERMINAL;
- else if (!strcmp (device_string, "listing"))
- device_type = SETTINGS_DEVICE_LISTING;
- else
- {
- msg (MW, _("%s is not a valid device type (the choices are `%s' and `%s')"),
- device_string, "terminal", "listing");
- device_type = default_device_type (file_name);
- }
-
- struct file_handle *fh = fh_create_file (NULL, file_name, NULL, fh_default_properties ());
-
- driver = f->create (fh, device_type, options);
- if (driver != NULL)
+ enum settings_output_devices default_type = default_device_type (file_name);
+ const char *default_type_string = (default_type == SETTINGS_DEVICE_TERMINAL
+ ? "terminal" : "listing");
+ enum settings_output_devices device_type = parse_enum (
+ driver_option_get (&o, "device", default_type_string),
+ "terminal", SETTINGS_DEVICE_TERMINAL,
+ "listing", SETTINGS_DEVICE_LISTING,
+ NULL_SENTINEL);
+
+ struct file_handle *fh = fh_create_file (NULL, file_name, NULL,
+ fh_default_properties ());
+ struct output_driver *driver = f->create (fh, device_type, &o);
+ if (driver)