diff options
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/config.c b/src/config.c index aa60323..69835b9 100644 --- a/src/config.c +++ b/src/config.c @@ -103,9 +103,6 @@ cb_format(enum grecs_callback_command cmd, grecs_value_t *value, void *cb_data) { - struct ec2_param *p, key; - int install = 1; - if (cmd != grecs_callback_set_value) { grecs_error(locus, 0, "Unexpected block statement"); return 1; @@ -119,9 +116,36 @@ cb_format(enum grecs_callback_command cmd, grecs_error(locus, 0, "expected two strings"); return 1; } + set_command_format(value->v.arg.v[0]->v.string, + value->v.arg.v[1]->v.string, + &value->v.arg.v[1]->locus); +} + +static int +cb_define_format(enum grecs_callback_command cmd, + grecs_locus_t *locus, + void *varptr, + grecs_value_t *value, + void *cb_data) +{ + if (cmd != grecs_callback_set_value) { + grecs_error(locus, 0, "Unexpected block statement"); + return 1; + } + if (!value || value->type != GRECS_TYPE_ARRAY || value->v.arg.c != 2) { + grecs_error(locus, 0, "expected two strings"); + return 1; + } + if (value->v.arg.v[0]->type != GRECS_TYPE_STRING || + value->v.arg.v[1]->type != GRECS_TYPE_STRING) { + grecs_error(locus, 0, "expected two strings"); + return 1; + } + define_format(value->v.arg.v[0]->v.string, value->v.arg.v[1]->v.string, &value->v.arg.v[1]->locus); + return 0; } static struct grecs_keyword eclat_kw[] = { @@ -138,8 +162,11 @@ static struct grecs_keyword eclat_kw[] = { "Define default AWS region", grecs_type_string, GRECS_DFLT, ®ion_name }, { "format", "<command: string> <format: string>", - "Set default format for the <command>", + "Set default format for <command>", grecs_type_string, GRECS_MULT, NULL, 0, cb_format }, + { "define-format", "<name: string> <format: string>", + "Define a named format", + grecs_type_string, GRECS_MULT, NULL, 0, cb_define_format }, { "format-file", "file", "Read format from <file>", grecs_type_string, GRECS_DFLT, &format_file }, { NULL } |