summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-04-28 00:53:01 -0400
committermidipix <writeonce@midipix.org>2016-04-28 00:53:01 -0400
commitb992f468001f21d9b3a83124a5eb320d41764cf4 (patch)
treee59e269c2bdbea40634ac561d2b09486127ec75b /src
parent959a9435744ad0515086156349fa424c2b5ef7d8 (diff)
downloadsofort-b992f468001f21d9b3a83124a5eb320d41764cf4.tar.bz2
sofort-b992f468001f21d9b3a83124a5eb320d41764cf4.tar.xz
utility: fancy --version.
Diffstat (limited to 'src')
-rw-r--r--src/sofort.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/sofort.c b/src/sofort.c
index 52ca314..434820a 100644
--- a/src/sofort.c
+++ b/src/sofort.c
@@ -8,19 +8,35 @@
| SFRT_DRIVER_VERBOSITY_USAGE
#endif
-static const char vermsg[] = "%s (git://midipix.org/sofort): "
- "version %d.%d.%d.\n"
- "[commit reference: %s]\n";
+static const char vermsg[] = "%s%s%s (git://midipix.org/sofort): "
+ "version %s%d.%d.%d%s.\n"
+ "[commit reference: %s%s%s]\n";
+
+static const char * const sfrt_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 sfrt_ver_plain[6] = {
+ "","",
+ "","",
+ "",""
+};
static ssize_t sofort_version(struct sfrt_driver_ctx * dctx)
{
const struct sfrt_source_version * verinfo;
+ const char * const * verclr;
verinfo = sfrt_source_version();
+ verclr = isatty(STDOUT_FILENO) ? sfrt_ver_color : sfrt_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 sofort_perform_unit_actions(struct sfrt_unit_ctx * uctx)