[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 16/39: [grog]: Alter usage message handling.
From: |
G. Branden Robinson |
Subject: |
[groff] 16/39: [grog]: Alter usage message handling. |
Date: |
Sat, 29 Oct 2022 14:59:57 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit d232be5301758977ee193822562cdcbcda3fe825
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Oct 24 17:14:19 2022 -0500
[grog]: Alter usage message handling.
* src/utils/grog/grog.pl: Alter usage message handling.
(help): Rename this subroutine...
(usage): ...to this. Summarize purpose of program and steer reader to
man page only if help was explicitly requested, rather than blitzing
user with text upon a usage error. Also drop option summary from
usage message, as it duplicates grog(1).
---
ChangeLog | 9 +++++++++
src/utils/grog/grog.pl | 38 +++++++++++++++++---------------------
2 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c0ce961d2..1fb159e5e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-10-24 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/utils/grog/grog.pl: Alter usage message handling.
+ (help): Rename this subroutine...
+ (usage): ...to this. Summarize purpose of program and steer
+ reader to man page only if help was explicitly requested, rather
+ than blitzing user with text upon a usage error. Also drop
+ option summary from usage message, as it duplicates grog(1).
+
2022-10-24 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/utils/grog/grog.pl: Drop relic code and comments.
diff --git a/src/utils/grog/grog.pl b/src/utils/grog/grog.pl
index 9652b55de..85fc9130f 100644
--- a/src/utils/grog/grog.pl
+++ b/src/utils/grog/grog.pl
@@ -144,7 +144,7 @@ sub process_arguments {
# Handle options that cause an early exit.
&version() if ($arg eq '-v' || $arg eq '--version');
- &help() if ($arg eq '-h' || $arg eq '--help');
+ &usage(0) if ($arg eq '-h' || $arg eq '--help');
if ($arg =~ '^--.') {
if ($arg =~ '^--(run|with-ligatures)$') {
@@ -152,6 +152,7 @@ sub process_arguments {
$pdf_with_ligatures = 1 if ($arg eq '--with-ligatures');
} else {
&fail("unrecognized grog option '$arg'; ignored");
+ &usage(1);
}
next;
}
@@ -666,27 +667,22 @@ sub construct_command {
} # construct_command()
-sub help {
+sub usage {
+ my $stream = *STDOUT;
+ my $had_error = shift;
+ $stream = *STDERR if $had_error;
my $grog = $program_name;
- print <<EOF;
-usage: $grog [--ligatures] [--run] [GROFF-OPTION ...] [--] [FILE ...]
- $grog { -h | --help | -v | --version }
-
-$grog reads each roff(7) input FILE and attempts to infer an appropriate
-groff(1) command to format it. If FILE is missing or is "-", then $grog
-reads the standard input stream. All arguments after a "--" argument
-are treated as FILEs.
-
-Options:
- -h, --help Display this uasge message and exit.
- --ligatures Include options '-P-y -PU' for gropdf(1) output driver,
- which produces ligatures. Requires '-T pdf'.
- --run Report inferred command to the standard error stream
- and then execute it.
- -v, --version Display version information and exit.
-EOF
- exit 0;
-} # help()
+ print $stream "usage: $grog [--ligatures] [--run]" .
+ " [groff-option ...] [--] [file ...]\n" .
+ "usage: $grog {-v | --version}\n" .
+ "usage: $grog {-h | --help}\n";
+ unless ($had_error) {
+ print $stream "\n" .
+"Read each roff(7) input FILE and attempt to infer an appropriate\n" .
+"groff(1) command to format it. See the grog(1) manual page.\n";
+ }
+ exit $had_error;
+}
sub version {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 16/39: [grog]: Alter usage message handling.,
G. Branden Robinson <=