summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-04-28 00:37:46 -0400
committermidipix <writeonce@midipix.org>2016-04-28 00:41:07 -0400
commit6cc0ddb5b0c44e855c6638d3b6838e0aa0f3e9e8 (patch)
tree2a4f8bae46dbcaa133f9dbb8b826b93e9e88755a
parentbfa8ca5c298987a72a421b04d93d434300aeb222 (diff)
downloadslibtool-6cc0ddb5b0c44e855c6638d3b6838e0aa0f3e9e8.tar.bz2
slibtool-6cc0ddb5b0c44e855c6638d3b6838e0aa0f3e9e8.tar.xz
utility: fancy --version.
-rw-r--r--src/slibtool.c28
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)