|
@@ -228,9 +228,9 @@ static struct command_descriptor choose_cmd =
|
228
|
228
|
*/
|
229
|
229
|
static int choose_exec ( int argc, char **argv ) {
|
230
|
230
|
struct choose_options opts;
|
|
231
|
+ struct named_setting setting;
|
231
|
232
|
struct menu *menu;
|
232
|
233
|
struct menu_item *item;
|
233
|
|
- const char *setting;
|
234
|
234
|
int rc;
|
235
|
235
|
|
236
|
236
|
/* Parse options */
|
|
@@ -238,7 +238,9 @@ static int choose_exec ( int argc, char **argv ) {
|
238
|
238
|
goto err_parse_options;
|
239
|
239
|
|
240
|
240
|
/* Parse setting name */
|
241
|
|
- setting = argv[optind];
|
|
241
|
+ if ( ( rc = parse_autovivified_setting ( argv[optind],
|
|
242
|
+ &setting ) ) != 0 )
|
|
243
|
+ goto err_parse_setting;
|
242
|
244
|
|
243
|
245
|
/* Identify menu */
|
244
|
246
|
if ( ( rc = parse_menu ( opts.menu, &menu ) ) != 0 )
|
|
@@ -248,11 +250,15 @@ static int choose_exec ( int argc, char **argv ) {
|
248
|
250
|
if ( ( rc = show_menu ( menu, opts.timeout, opts.select, &item ) ) != 0)
|
249
|
251
|
goto err_show_menu;
|
250
|
252
|
|
|
253
|
+ /* Apply default type if necessary */
|
|
254
|
+ if ( ! setting.setting.type )
|
|
255
|
+ setting.setting.type = &setting_type_string;
|
|
256
|
+
|
251
|
257
|
/* Store setting */
|
252
|
|
- if ( ( rc = storef_named_setting ( setting, &setting_type_string,
|
253
|
|
- item->label ) ) != 0 ) {
|
|
258
|
+ if ( ( rc = storef_setting ( setting.settings, &setting.setting,
|
|
259
|
+ item->label ) ) != 0 ) {
|
254
|
260
|
printf ( "Could not store \"%s\": %s\n",
|
255
|
|
- setting, strerror ( rc ) );
|
|
261
|
+ setting.setting.name, strerror ( rc ) );
|
256
|
262
|
goto err_store;
|
257
|
263
|
}
|
258
|
264
|
|
|
@@ -265,6 +271,7 @@ static int choose_exec ( int argc, char **argv ) {
|
265
|
271
|
if ( ! opts.keep )
|
266
|
272
|
destroy_menu ( menu );
|
267
|
273
|
err_parse_menu:
|
|
274
|
+ err_parse_setting:
|
268
|
275
|
err_parse_options:
|
269
|
276
|
return rc;
|
270
|
277
|
}
|