summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhiseck Paira <abhiseckpaira@disroot.org>2022-07-01 20:49:26 +0530
committerDavid Thompson <dthompson@vistahigherlearning.com>2022-07-07 09:45:34 -0400
commit663029ce4dd98774ed0cd5888741a9658758bbc6 (patch)
treede33bba0fb5dd8ed4eead13a69671fa408b97a0a
parentbc5455537fc07b325fd16a0e09bc220ca9e5f759 (diff)
ui: Recognize --help and --version when other arguments follow.
From 881446873325df909f0b9779a8b347dee276f2c9 Mon Sep 17 00:00:00 2001 From: Abhiseck Paira <abhiseckpaira@disroot.org> Date: Fri, 1 Jul 2022 20:00:57 +0530 Subject: [PATCH] fix(ui): recognize -h when it's 1st arg in a multi arg command line When shroud is called with multiple arguments with -h (or --version) as the first argument, it fails to recognize -h (or --version) and prints "unrecognized option '-h'" in the shell. For example following command would not print help information: $ shroud -h list instead shroud complains that -h is an unrecognized option. Change the pattern in `match' macro call in the function `shroud-main' so that when -h (or --version) is first argument, it is recognized and appropriate action is invoked. Rest of the arguments are discarded. * shroud/ui.scm (shroud-main): Modify pattern in `match' macro call to match "-h", "--help" (or "--version") when it's the first argument in a multiple argument command line. Discard the rest of the arguments.
-rw-r--r--shroud/ui.scm8
1 files changed, 6 insertions, 2 deletions
diff --git a/shroud/ui.scm b/shroud/ui.scm
index 51cb412..7f22fd1 100644
--- a/shroud/ui.scm
+++ b/shroud/ui.scm
@@ -153,9 +153,13 @@ ARGS is the list of arguments received by the 'throw' handler."
(define (shroud-main . args)
(match args
(() (show-usage))
- ((or ("-h") ("--help"))
+ ;; Match if first argument is "-h" or "--help", ignoring the rest
+ ;; of the arguments.
+ (((or "-h" "--help") . _)
(show-help))
- (("--version")
+ ;; Match if first argument is "--version", ignoring the rest of
+ ;; the arguments.
+ (("--version" . _)
(show-version-and-exit))
(((? option? opt) _ ...)
(format (current-error-port) "shroud: unrecognized option '~a'~%" opt))