[libcamera-devel] [PATCH] cam: options: Indent multi-line help message correctly

Niklas Söderlund niklas.soderlund at ragnatech.se
Sun Jan 27 01:26:23 CET 2019


Hi Laurent,

Neat idea!

On 2019-01-26 17:16:59 +0200, Laurent Pinchart wrote:
> Split multi-line help messages and indent all lines the same way.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>

> ---
>  src/cam/options.cpp | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/src/cam/options.cpp b/src/cam/options.cpp
> index 55c42540f924..83601270207b 100644
> --- a/src/cam/options.cpp
> +++ b/src/cam/options.cpp
> @@ -153,7 +153,17 @@ void OptionsParser::usage()
>  		}
>  
>  		std::cerr << std::setw(indent) << std::left << argument;
> -		std::cerr << option.help << std::endl;
> +
> +		for (const char *help = option.help, *end = help; end; ) {
> +			end = strchr(help, '\n');
> +			if (end) {
> +				std::cerr << std::string(help, end - help + 1);
> +				std::cerr << std::setw(indent) << " ";
> +				help = end + 1;
> +			} else {
> +				std::cerr << help << std::endl;
> +			}
> +		}
>  	}
>  }
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

-- 
Regards,
Niklas Söderlund


More information about the libcamera-devel mailing list