diff mbox series

[1/1] utils: Add help text for v4l2-tracer-gen.pl

Message ID 20230221160849.2778-1-sakari.ailus@linux.intel.com
State New
Headers show
Series Switch build system to meson | expand

Commit Message

Sakari Ailus Feb. 21, 2023, 4:08 p.m. UTC
Add help text for v4l2-tracer-gen.pl, via the '-h' option. Also add
support for '--' to signal end of options, in case file names would begin
with dash.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
Hi Laurent,

Can you squash this to the utils patch?

- Sakari

 utils/v4l2-tracer/v4l2-tracer-gen.pl | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/utils/v4l2-tracer/v4l2-tracer-gen.pl b/utils/v4l2-tracer/v4l2-tracer-gen.pl
index 8192a5bf..53473ae1 100755
--- a/utils/v4l2-tracer/v4l2-tracer-gen.pl
+++ b/utils/v4l2-tracer/v4l2-tracer-gen.pl
@@ -8,8 +8,26 @@  my %outtype = ( "common" => 1, "trace" => 1, "retrace" => 1 );
 while ($ARGV[0] =~ /^-/) {
 	my $arg = shift @ARGV;
 
-	$outdir = shift @ARGV if $arg eq "-o";
-	%outtype = (shift @ARGV => 1) if $arg eq '-t';
+	($outdir = shift @ARGV) && next if $arg eq "-o";
+	(%outtype = (shift @ARGV => 1)) && next if $arg eq '-t';
+	(help() && exit 0) if $arg eq '-h';
+	last if $arg eq '--';
+
+	print stderr "invalid option $arg, use $0 -h for help\n";
+	exit 0;
+}
+
+sub help() {
+	print stderr <<EOF;
+$0 - Generate files for V4L2 tracer
+
+usage: $0 [-o dir] [-t (common|trace|retrace)] [-h] header [header2] ...
+
+	-o dir	set output directory
+	-t x	generate particular trace files, the default is to generate
+		them all
+	-h	print this help text and quit
+EOF
 }
 
 sub convert_type_to_json_type {