diff --git a/tag.c b/tag.c index f97b2a4..1bbb270 100644 --- a/tag.c +++ b/tag.c @@ -450,8 +450,27 @@ tags_expand_template(const char *template, const struct tag_set *tags) sbuf_append_at_most(&formatted, template, begin - template); /* Copy tag value */ - const char *value = tag->as_string(tag); - sbuf_append(&formatted, value); + if (tag_arg == NULL) { + const char *value = tag->as_string(tag); + sbuf_append(&formatted, value); + } else if (strcmp(tag_arg, "min") == 0 || + strcmp(tag_arg, "max") == 0) + { + long value = strcmp(tag_arg, "min") == 0 ? tag->min(tag) : tag->max(tag); + char str[24]; + snprintf(str, sizeof(str), "%ld", value); + sbuf_append(&formatted, str); + } else if (strcmp(tag_arg, "unit") == 0) { + const char *value = NULL; + + switch (tag->realtime(tag)) { + case TAG_REALTIME_NONE: value = ""; break; + case TAG_REALTIME_SECS: value = "s"; break; + case TAG_REALTIME_MSECS: value = "ms"; break; + } + + sbuf_append(&formatted, value); + } /* Skip past tag name + closing '}' */ template = end + 1;