summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2021-04-03 20:06:13 +0000
committermidipix <writeonce@midipix.org>2021-05-05 17:24:55 +0000
commit5e509f3f5911d71eb3586234e5bf815f8623f649 (patch)
tree151796effb04a7d679015a03c4836edb4614e4a0 /src
parentf6c28566026ff1b64e74142577522ab0583a5c1f (diff)
downloadapimagic-5e509f3f5911d71eb3586234e5bf815f8623f649.tar.bz2
apimagic-5e509f3f5911d71eb3586234e5bf815f8623f649.tar.xz
argv.h: tty colors: added argv_usage_plain().
Diffstat (limited to 'src')
-rw-r--r--src/internal/argv/argv.h34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h
index 65fe591..62a2653 100644
--- a/src/internal/argv/argv.h
+++ b/src/internal/argv/argv.h
@@ -150,6 +150,12 @@ static void argv_usage(
const struct argv_option **,
const char * mode);
+static void argv_usage_plain(
+ int fd,
+ const char * header,
+ const struct argv_option **,
+ const char * mode);
+
static struct argv_meta * argv_get(
char **,
const struct argv_option **,
@@ -763,11 +769,12 @@ static void argv_free(struct argv_meta * xmeta)
}
}
-static void argv_usage(
+static void argv_usage_impl(
int fd,
const char * header,
const struct argv_option ** options,
- const char * mode)
+ const char * mode,
+ int fcolor)
{
const struct argv_option ** optv;
const struct argv_option * option;
@@ -789,12 +796,13 @@ static void argv_usage(
const char cblue [] = "\x1b[34m";
const char ccyan [] = "\x1b[36m";
const char * color = ccyan;
- bool fcolor;
+
+ (void)argv_usage;
+ (void)argv_usage_plain;
fshort = mode ? !strcmp(mode,"short") : 0;
flong = fshort ? 0 : mode && !strcmp(mode,"long");
fboth = !fshort && !flong;
- fcolor = isatty(fd);
if (fcolor)
argv_dprintf(fd,"%s%s",cbold,cgreen);
@@ -936,6 +944,24 @@ static void argv_usage(
argv_dprintf(fd,creset);
}
+static void argv_usage(
+ int fd,
+ const char * header,
+ const struct argv_option ** options,
+ const char * mode)
+{
+ argv_usage_impl(fd,header,options,mode,isatty(fd));
+}
+
+static void argv_usage_plain(
+ int fd,
+ const char * header,
+ const struct argv_option ** options,
+ const char * mode)
+{
+ argv_usage_impl(fd,header,options,mode,0);
+}
+
#endif
#endif