summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-04-28 00:40:28 -0400
committermidipix <writeonce@midipix.org>2016-04-28 00:59:37 -0400
commite0b135b6c155f55d93161b39368a0241890ae152 (patch)
tree7d4f1f4fe05e21152d06b1244f1e02414a16a937 /src
parent22223cec22db107b711f1d59856971aed3c05bc6 (diff)
downloadapimagic-e0b135b6c155f55d93161b39368a0241890ae152.tar.bz2
apimagic-e0b135b6c155f55d93161b39368a0241890ae152.tar.xz
utility: fancy --version.
Diffstat (limited to 'src')
-rw-r--r--src/apimagic.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/apimagic.c b/src/apimagic.c
index f7fbf2f..0303949 100644
--- a/src/apimagic.c
+++ b/src/apimagic.c
@@ -14,19 +14,35 @@
| AMGC_DRIVER_VERBOSITY_USAGE
#endif
-static const char vermsg[] = "%s (git://midipix.org/apimagic): "
- "version %d.%d.%d.\n"
- "[commit reference: %s]\n";
+static const char vermsg[] = "%s%s%s (git://midipix.org/apimagic): "
+ "version %s%d.%d.%d%s.\n"
+ "[commit reference: %s%s%s]\n";
+
+static const char * const amgc_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 amgc_ver_plain[6] = {
+ "","",
+ "","",
+ "",""
+};
static ssize_t apimagic_version(struct amgc_driver_ctx * dctx)
{
const struct amgc_source_version * verinfo;
+ const char * const * verclr;
verinfo = amgc_source_version();
+ verclr = isatty(STDOUT_FILENO) ? amgc_ver_color : amgc_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 apimagic_perform_unit_actions(struct amgc_unit_ctx * uctx)