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 11f11d7ecb
.
Co-authored-by: Ludovic Courtès <ludo@gnu.org>
master
parent
ee3226e9d5
commit
e68ae7f00e
|
@ -118,7 +118,12 @@ procedure, but both the category and synopsis are meant to be read (parsed) by
|
||||||
according to'string-distance'."
|
according to'string-distance'."
|
||||||
(define (options->long-names options)
|
(define (options->long-names options)
|
||||||
(filter string? (append-map option-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)
|
(define (args-fold* args options unrecognized-option-proc operand-proc . seeds)
|
||||||
"A wrapper on top of `args-fold' that does proper user-facing error
|
"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.
|
;; Actual parsing takes place here.
|
||||||
(apply args-fold* args options
|
(apply args-fold* args options
|
||||||
(lambda (opt name arg . rest)
|
(lambda (opt name arg . rest)
|
||||||
(let ((hint (and (string? name) ;not a short option
|
(let ((hint (option-hint name options)))
|
||||||
(option-hint name options))))
|
|
||||||
(report-error (G_ "~A: unrecognized option~%") name)
|
(report-error (G_ "~A: unrecognized option~%") name)
|
||||||
(when hint
|
(when hint
|
||||||
(display-hint
|
(display-hint
|
||||||
|
|
Reference in New Issue