Instead of declaring -color and -json exclusive, ignore -color when
-json is provided. The rationale is to allow to put -color in an alias
for ip while still being able to use -json. -color is merely a
presentation suggestion and we can assume there is nothing to color in
the JSON output.
Signed-off-by: Vincent Bernat <vincent@bernat.im>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
};
void enable_color(void);
-void check_if_color_enabled(void);
void set_color_palette(void);
int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...);
enum color_attr ifa_family_color(__u8 ifa_family);
{
char *basename;
char *batch_file = NULL;
+ int color = 0;
basename = strrchr(argv[0], '/');
if (basename == NULL)
}
rcvbuf = size;
} else if (matches(opt, "-color") == 0) {
- enable_color();
+ ++color;
} else if (matches(opt, "-help") == 0) {
usage();
} else if (matches(opt, "-netns") == 0) {
_SL_ = oneline ? "\\" : "\n";
- if (json)
- check_if_color_enabled();
+ if (color && !json)
+ enable_color();
if (batch_file)
return batch(batch_file);
is_dark_bg = 1;
}
-void check_if_color_enabled(void)
-{
- if (color_is_enabled) {
- fprintf(stderr, "Option \"-json\" conflicts with \"-color\".\n");
- exit(1);
- }
-}
-
int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...)
{
int ret = 0;