diff options
author | midipix <writeonce@midipix.org> | 2016-04-28 00:52:06 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-11-10 23:35:43 -0500 |
commit | 8435a6e9b91eb4f479a65a64a1a7761da4633a99 (patch) | |
tree | 4f0f31d29265c2dd937325b363333b1f5184242c /src | |
parent | 9f9f2d66aaad5f5f43dcb20f6aa09eeab3f26925 (diff) | |
download | perk-8435a6e9b91eb4f479a65a64a1a7761da4633a99.tar.bz2 perk-8435a6e9b91eb4f479a65a64a1a7761da4633a99.tar.xz |
utility: fancy --version.
Diffstat (limited to 'src')
-rw-r--r-- | src/perk.c | 28 |
1 files changed, 22 insertions, 6 deletions
@@ -15,19 +15,35 @@ | PERK_DRIVER_VERBOSITY_USAGE #endif -static const char vermsg[] = "%s (git://midipix.org/perk): " - "version %d.%d.%d.\n" - "[commit reference: %s]\n"; +static const char vermsg[] = "%s%s%s (git://midipix.org/perk): " + "version %s%d.%d.%d%s.\n" + "[commit reference: %s%s%s]\n"; + +static const char * const pe_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 pe_ver_plain[6] = { + "","", + "","", + "","" +}; static ssize_t perk_version(struct pe_driver_ctx * dctx) { const struct pe_source_version * verinfo; + const char * const * verclr; verinfo = pe_source_version(); + verclr = isatty(STDOUT_FILENO) ? pe_ver_color : pe_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 ssize_t perk_paragraph_break(struct pe_unit_ctx * uctx, int * fpara) |