;;; Click --- Command Line Interface Creation Kit for GNU Guile ;;; Copyright © 2021 Javier Sancho ;;; ;;; 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 . (define-module (click) #:use-module (ice-9 getopt-long) #:use-module (click constant) #:use-module (click display) #:use-module (click util) #:export (command)) (define (command option-spec procedure) (lambda (args) (with-fluids ((%program-name (car args))) (let* ((click-option-spec (append option-spec (list HELP_OPTION))) (values (getopt-long args (getopt-long-option-spec click-option-spec)))) (if (option-ref values 'help #f) (display-help procedure click-option-spec) (apply procedure (map cdr (get-values option-spec values))))))))