mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hannes Eder <hannes@hanneseder.net>
To: Andy Whitcroft <apw@canonical.com>
Cc: Pavel Machek <pavel@suse.cz>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] checkpatch: make -f alias --file, add --help, more verbose help message
Date: Tue, 10 Mar 2009 18:21:23 +0100	[thread overview]
Message-ID: <20090310172026.10948.10453.stgit@f10box.hanneseder.net> (raw)
In-Reply-To: <20090120103219.GK2576@elf.ucw.cz>

Impact:
  - More verbose help/usage message.
  - Make the option -f an alias for --file.
  - On -h, --help, and --version display help message and exit(0).
  - With no FILE(s) given, exit(1) with "no input files".
  - On invalid options display help/usage and exit(1).

Based on a patch by Pavel Machek.

Signed-off-by: Hannes Eder <hannes@hanneseder.net>
Cc: Pavel Machek <pavel@suse.cz>
---

parts from the original mail:

On Tue, Jan 20, 2009 at 11:32 AM, Pavel Machek <pavel@suse.cz> wrote:
> Subject: checkpatch fun (was Re: hp accelerometer: add freefall detection)
>
> [... skip ...]
>
> I tried checkpatch-ing a file, and not only my attempts to use it
> failed, my attempts to get help failed too.
>
> pavel@amd:/data/l/linux/Documentation$ ../scripts/checkpatch.pl hwmon/hpfall.c
> ERROR: Does not appear to be a unified-diff format patch
> ....
> pavel@amd:/data/l/linux/Documentation$ ../scripts/checkpatch.pl -f hwmon/hpfall.c
> Unknown option: f
> pavel@amd:/data/l/linux/Documentation$ ../scripts/checkpatch.pl -h
> Unknown option: h
> pavel@amd:/data/l/linux/Documentation$ ../scripts/checkpatch.pl --help
> Unknown option: help
>
> [... skip ...]
>

 scripts/checkpatch.pl |   55 +++++++++++++++++++++++++++++++++++++------------
 1 files changed, 42 insertions(+), 13 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2d5ece7..1e730be 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -28,6 +28,41 @@ my $mailback = 0;
 my $summary_file = 0;
 my $root;
 my %debug;
+my $help = 0;
+
+sub help {
+	my ($exitcode) = @_;
+
+	print << "EOM";
+Usage: $P [OPTION]... [FILE]...
+Version: $V
+
+Options:
+  -q, --quiet                quiet
+  --no-tree                  run without a kernel tree
+  --no-signoff               do not check for 'Signed-off-by' line
+  --patch                    treat FILE as patchfile (default)
+  --emacs                    emacs compile window format
+  --terse                    one line per report
+  -f, --file                 treat FILE as regular source file
+  --subjective, --strict     enable more subjective tests
+  --root=PATH                PATH to the kernel tree root
+  --no-summary               suppress the per-file summary
+  --mailback                 only produce a report in case of warnings/errors
+  --summary-file             include the filename in summary
+  --debug KEY=[0|1]          turn on/off debugging of KEY, where KEY is one of
+                             'values', 'possible', 'type', and 'attr' (default
+                             is all off)
+  --test-only=WORD           report only warnings/errors containing WORD
+                             literally
+  -h, --help, --version      display this help and exit
+
+When FILE is - read standard input.
+EOM
+
+	exit($exitcode);
+}
+
 GetOptions(
 	'q|quiet+'	=> \$quiet,
 	'tree!'		=> \$tree,
@@ -35,7 +70,7 @@ GetOptions(
 	'patch!'	=> \$chk_patch,
 	'emacs!'	=> \$emacs,
 	'terse!'	=> \$terse,
-	'file!'		=> \$file,
+	'f|file!'	=> \$file,
 	'subjective!'	=> \$check,
 	'strict!'	=> \$check,
 	'root=s'	=> \$root,
@@ -45,22 +80,16 @@ GetOptions(
 
 	'debug=s'	=> \%debug,
 	'test-only=s'	=> \$tst_only,
-) or exit;
+	'h|help'	=> \$help,
+	'version'	=> \$help
+) or help(1);
+
+help(0) if ($help);
 
 my $exit = 0;
 
 if ($#ARGV < 0) {
-	print "usage: $P [options] patchfile\n";
-	print "version: $V\n";
-	print "options: -q               => quiet\n";
-	print "         --no-tree        => run without a kernel tree\n";
-	print "         --terse          => one line per report\n";
-	print "         --emacs          => emacs compile window format\n";
-	print "         --file           => check a source file\n";
-	print "         --strict         => enable more subjective tests\n";
-	print "         --root           => path to the kernel tree root\n";
-	print "         --no-summary     => suppress the per-file summary\n";
-	print "         --summary-file   => include the filename in summary\n";
+	print "$P: no input files\n";
 	exit(1);
 }
 


  reply	other threads:[~2009-03-10 17:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-12  9:29 hp accelerometer: fix LED handling and add freefall detection Pavel Machek
2009-01-12  9:33 ` Éric Piel
     [not found]   ` <fd6b62c10901120150q6b00640dm72c0ec5d0bd7a9e2@mail.gmail.com>
2009-01-12 10:02     ` Pavel Machek
2009-01-16 12:19   ` hp accelerometer: " Pavel Machek
2009-01-16 22:34     ` Andrew Morton
2009-01-20 10:32       ` checkpatch fun (was Re: hp accelerometer: add freefall detection) Pavel Machek
2009-03-10 17:21         ` Hannes Eder [this message]
2009-03-10 18:10           ` [PATCH] checkpatch: make -f alias --file, add --help, more verbose help message Andy Whitcroft
2009-03-10 18:52             ` Andy Whitcroft
2009-03-11  8:18           ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090310172026.10948.10453.stgit@f10box.hanneseder.net \
    --to=hannes@hanneseder.net \
    --cc=apw@canonical.com \
    --cc=pavel@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®