On Wed, Mar 02, 2016 at 03:56:16PM +0100, Quentin Monnet wrote: > Add an option to ovs-ofctl utility so as to obtain colorized output in > tty, for easier reading. Currently, only the dump-flows command supports > colors. > > A new `--color` option has been added to ovs-ofctl so as to indicate > whether color markers should be used or not. It can be set to `always` > (force colors), `never` (no colors) or `auto` (use colors only if output > is a tty). If provided without any value, it is the same as `auto`. If > the option is not provided at all, colors are disabled by default. > > Examples: > This first call will output colorized flows: > > ovs-ofctl dump-flows br0 --color=always > > These two calls will produce colorized output on a tty, but they will > not use color markers if the output is redirected to a file or piped > into another command: > > ovs-ofctl dump-flows br0 --color=auto > ovs-ofctl dump-flows br0 --color > > These two calls will not use color markers: > > ovs-ofctl dump-flows br0 --color=never > ovs-ofctl dump-flows br0 > > The result of this option is stored into a variable which is to be > forwarded (in next commits) as a function argument until it reaches the > functions that print the elements of the flows. > > Signed-off-by: Quentin Monnet <quentin.mon...@6wind.com>
Thanks. I'm going to fold in the following style fixes: diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index c535005..db59ff6 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -296,28 +296,24 @@ parse_options(int argc, char *argv[]) case OPT_COLOR: if (optarg) { - if (!strcasecmp (optarg, "always") - || !strcasecmp (optarg, "yes") - || !strcasecmp (optarg, "force")) { + if (!strcasecmp(optarg, "always") + || !strcasecmp(optarg, "yes") + || !strcasecmp(optarg, "force")) { enable_color = true; - } - else if (!strcasecmp (optarg, "never") - || !strcasecmp (optarg, "no") - || !strcasecmp (optarg, "none")) { + } else if (!strcasecmp(optarg, "never") + || !strcasecmp(optarg, "no") + || !strcasecmp(optarg, "none")) { enable_color = false; - } - /* If --color is empty or set to 'auto', determine whether we - * need colors, i.e. whether standard output is a tty. */ - else if (!strcasecmp (optarg, "auto") - || !strcasecmp (optarg, "tty") - || !strcasecmp (optarg, "if-tty")) { + } else if (!strcasecmp(optarg, "auto") + || !strcasecmp(optarg, "tty") + || !strcasecmp(optarg, "if-tty")) { + /* Determine whether we need colors, i.e. whether standard + * output is a tty. */ enable_color = is_stdout_a_tty(); - } - else { + } else { ovs_fatal(0, "incorrect value `%s' for --color", optarg); } - } - else { + } else { enable_color = is_stdout_a_tty(); } break; @@ -450,7 +446,7 @@ usage(void) " --sort[=field] sort in ascending order\n" " --rsort[=field] sort in descending order\n" " --unixctl=SOCKET set control socket name\n" - " --color[=always|never|auto] use colors markers\n" + " --color[=always|never|auto] control use of color in output\n" " -h, --help display this help message\n" " -V, --version display version information\n"); exit(EXIT_SUCCESS); _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev