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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx>
---
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 --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 {
-- 
2.30.2




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux