[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/06: guix: scripts: Fix corner cases of hint for option typo.
From: |
guix-commits |
Subject: |
04/06: guix: scripts: Fix corner cases of hint for option typo. |
Date: |
Wed, 24 Feb 2021 18:13:57 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit e68ae7f00e2e9817dacb301a97289da68efed5a1
Author: zimoun <zimon.toutoune@gmail.com>
AuthorDate: Fri Feb 5 00:02:50 2021 +0100
guix: scripts: Fix corner cases of hint for option typo.
* guix/scripts.scm (option-hint): Fix corner cases.
(parse-command-line)[parse-options-from]: Remove 'string?' check
introduced in 11f11d7ecb817d1421f8b5340bcced59396d8708.
Co-authored-by: Ludovic Courtès <ludo@gnu.org>
---
guix/scripts.scm | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/guix/scripts.scm b/guix/scripts.scm
index 0c896a2..3aabaf5 100644
--- a/guix/scripts.scm
+++ b/guix/scripts.scm
@@ -118,7 +118,12 @@ procedure, but both the category and synopsis are meant to
be read (parsed) by
according to'string-distance'."
(define (options->long-names options)
(filter string? (append-map option-names options)))
- (string-closest guess (options->long-names options) #:threshold 3))
+ (match guess
+ ((? string?)
+ (match (string-split guess #\=)
+ ((name rest ...)
+ (string-closest name (options->long-names options) #:threshold 3))))
+ (_ #f)))
(define (args-fold* args options unrecognized-option-proc operand-proc . seeds)
"A wrapper on top of `args-fold' that does proper user-facing error
@@ -157,8 +162,7 @@ parameter of 'args-fold'."
;; Actual parsing takes place here.
(apply args-fold* args options
(lambda (opt name arg . rest)
- (let ((hint (and (string? name) ;not a short option
- (option-hint name options))))
+ (let ((hint (option-hint name options)))
(report-error (G_ "~A: unrecognized option~%") name)
(when hint
(display-hint
- branch master updated (570c9c9 -> fc03a1a), guix-commits, 2021/02/24
- 06/06: gnu: Add chili-sddm-theme., guix-commits, 2021/02/24
- 04/06: guix: scripts: Fix corner cases of hint for option typo.,
guix-commits <=
- 05/06: gnu: solaar: Add missing dependencies for the GUI., guix-commits, 2021/02/24
- 03/06: substitute: Ensure backtraces go to file descriptor 4., guix-commits, 2021/02/24
- 02/06: substitute: Do not unwind stack traces upon uncaught exceptions., guix-commits, 2021/02/24
- 01/06: ui: Bug-report URL in '--help' can be translated., guix-commits, 2021/02/24