From b4d25082fd4502ec01d511c22fecd60d513b81f4 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Fri, 14 Jul 2017 12:57:41 +0200 Subject: gpgscm: Library improvements. * tests/gpgscm/repl.scm (prompt-yes-no?): New function. * tests/gpgscm/tests.scm (pathsep-split): Likewise. (pathsep-join): Likewise. (with-path): Use the new function. Signed-off-by: Justus Winter --- tests/gpgscm/repl.scm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/gpgscm/repl.scm') diff --git a/tests/gpgscm/repl.scm b/tests/gpgscm/repl.scm index 84454dc7c..833ec0dec 100644 --- a/tests/gpgscm/repl.scm +++ b/tests/gpgscm/repl.scm @@ -55,3 +55,15 @@ (define (interactive-repl . environment) (repl (lambda (p) (prompt-append-prefix "gpgscm " p)) (if (null? environment) (interaction-environment) (car environment)))) + +;; Ask a yes/no question. +(define (prompt-yes-no? question default) + (let ((answer (prompt (string-append question "? [" + (if default "Y/n" "y/N") "] ")))) + (cond + ((= 0 (string-length answer)) + default) + ((or (equal? "y" answer) (equal? "Y" answer)) + #t) + (else + #f)))) -- cgit v1.2.3