]> git.jsancho.org Git - guile-click.git/commitdiff
Move value functions to a separated file
authorJavier Sancho <jsf@jsancho.org>
Fri, 10 Sep 2021 16:33:06 +0000 (18:33 +0200)
committerJavier Sancho <jsf@jsancho.org>
Fri, 10 Sep 2021 16:33:06 +0000 (18:33 +0200)
click.scm
click/util.scm
click/value.scm [new file with mode: 0644]

index aa804306de2fd2ec6d2ebd2a5864e28ef83fd78f..6a2d25323113da8c030307ab52452aff4d6e0ef0 100644 (file)
--- a/click.scm
+++ b/click.scm
@@ -22,6 +22,7 @@
   #:use-module (click constant)
   #:use-module (click display)
   #:use-module (click util)
+  #:use-module (click value)
   #:export (command))
 
 
index e83e15319a915d16cb43e2ab4cfc14efe207126b..8a4f771676e14e985772e1d08c8af37cc3c95e62 100644 (file)
@@ -22,9 +22,6 @@
   #:use-module (ice-9 readline)
   #:use-module (click constant)
   #:export (getopt-long-option-spec
-            get-option-default-value
-            get-values
-            option-default-value
             option-property
             program-name
             %program-name))
     (if property
         (cadr property)
         default)))
-
-(define (get-values option-spec values)
-  "Return an associated list with values for all the options in option-spec"
-  (cond ((null? option-spec)
-         '())
-        (else
-         (let* ((option (car option-spec))
-                (option-name (car option))
-                (value (or (option-ref values option-name #f)
-                           (get-option-default-value option))))
-           (cons (cons option-name value)
-                 (get-values (cdr option-spec) values))))))
-
-
-(define* (get-option-default-value option #:optional (no-prompt #f))
-  "Get value for option, asking user if prompt property is set"
-  (let ((default (option-property option 'default)))
-    (if (not default)
-        (let ((prompt (option-property option 'prompt)))
-          (if prompt
-              (readline (format #f "~a: " prompt))
-              default))
-        default)))
diff --git a/click/value.scm b/click/value.scm
new file mode 100644 (file)
index 0000000..ec00445
--- /dev/null
@@ -0,0 +1,49 @@
+;;; Click --- Command Line Interface Creation Kit for GNU Guile
+;;; Copyright © 2021 Javier Sancho <jsf@jsancho.org>
+;;;
+;;; This file is part of Click.
+;;;
+;;; Click is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; Click is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with Click.  If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (click value)
+  #:use-module (ice-9 getopt-long)
+  #:use-module (ice-9 readline)
+  #:use-module (click util)
+  #:export (get-option-default-value
+            get-values))
+
+
+(define (get-values option-spec values)
+  "Return an associated list with values for all the options in option-spec"
+  (cond ((null? option-spec)
+         '())
+        (else
+         (let* ((option (car option-spec))
+                (option-name (car option))
+                (value (or (option-ref values option-name #f)
+                           (get-option-default-value option))))
+           (cons (cons option-name value)
+                 (get-values (cdr option-spec) values))))))
+
+
+(define* (get-option-default-value option #:optional (no-prompt #f))
+  "Get value for option, asking user if prompt property is set"
+  (let ((default (option-property option 'default)))
+    (if (not default)
+        (let ((prompt (option-property option 'prompt)))
+          (if prompt
+              (readline (format #f "~a: " prompt))
+              default))
+        default)))