diff mbox series

[bug#46308,1/1] guix: scripts: Fix corner cases of hint for option typo.

Message ID 20210204230250.3304-1-zimon.toutoune@gmail.com
State Accepted
Headers show
Series Fix 2 corner cases for option hint | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Simon Tournier Feb. 4, 2021, 11:02 p.m. UTC
* guix/scripts.scm (option-hint): Fix corner cases.
---
 guix/scripts.scm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Ludovic Courtès Feb. 24, 2021, 10:51 p.m. UTC | #1
Hi,

zimoun <zimon.toutoune@gmail.com> skribis:

> * guix/scripts.scm (option-hint): Fix corner cases.

Applied!  I also reverted the change I made in
11f11d7ecb817d1421f8b5340bcced59396d8708, which addressed the
short-option problem you mention.

Thanks,
Ludo’.
diff mbox series

Patch

diff --git a/guix/scripts.scm b/guix/scripts.scm
index c9ea9f2e29..1773894bc2 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