[ovs-dev] [ovs-dev, v2, 1/6] ovs-ofctl: add option for color output to dump-flows command

Ben Pfaff blp at ovn.org
Tue Feb 23 23:08:51 UTC 2016


On Mon, Feb 15, 2016 at 04:20:33PM +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.monnet at 6wind.com>

Thanks for working on this.

Please introduce an enum for the color setting, instead of using
numbers.  (Alternatively you could change it to a bool and then, instead
of assigning a special value for "auto", just call a function that
determines whether stdout is a tty.)

When optarg is invalid, please report an appropriate error to the user
instead of displaying the usage message.

Please update the ovs-ofctl manpage.

Please update NEWS.

Usually we wouldn't add a new user option without actually implementing
it, so probably this patch should be combined with one or more of the
following patches (I haven't reviewed them yet).

Thanks,

Ben.



More information about the dev mailing list