diff options
Diffstat (limited to 'src/slibtool.c')
-rw-r--r-- | src/slibtool.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/slibtool.c b/src/slibtool.c index e3bf2bb..6548099 100644 --- a/src/slibtool.c +++ b/src/slibtool.c @@ -15,19 +15,35 @@ | SLBT_DRIVER_VERBOSITY_USAGE #endif -static const char vermsg[] = "%s (git://midipix.org/slibtool): " - "version %d.%d.%d.\n" - "[commit reference: %s]\n"; +static const char vermsg[] = "%s%s%s (git://midipix.org/slibtool): " + "version %s%d.%d.%d%s.\n" + "[commit reference: %s%s%s]\n"; + +static const char * const slbt_ver_color[6] = { + "\e[1m\e[35m","\e[0m", + "\e[1m\e[32m","\e[0m", + "\e[1m\e[34m","\e[0m" +}; + +static const char * const slbt_ver_plain[6] = { + "","", + "","", + "","" +}; static ssize_t slibtool_version(struct slbt_driver_ctx * dctx) { const struct slbt_source_version * verinfo; + const char * const * verclr; verinfo = slbt_source_version(); + verclr = isatty(STDOUT_FILENO) ? slbt_ver_color : slbt_ver_plain; - return fprintf(stdout,vermsg,dctx->program, - verinfo->major,verinfo->minor,verinfo->revision, - verinfo->commit); + return fprintf(stdout,vermsg, + verclr[0],dctx->program,verclr[1], + verclr[2],verinfo->major,verinfo->minor, + verinfo->revision,verclr[3], + verclr[4],verinfo->commit,verclr[5]); } static void slibtool_perform_driver_actions(struct slbt_driver_ctx * dctx) |