X-Git-Url: https://git.jsancho.org/?p=guile-click.git;a=blobdiff_plain;f=click%2Fdisplay.scm;fp=click%2Fdisplay.scm;h=0000000000000000000000000000000000000000;hp=968a063e1677df54684c2a4a3fcc18229c60af33;hb=ebf74b7c3fda8ead57a398bb6a1555067150d06f;hpb=ee290f19711b9e4fb789a0b2a164635e7140a8e5 diff --git a/click/display.scm b/click/display.scm deleted file mode 100644 index 968a063..0000000 --- a/click/display.scm +++ /dev/null @@ -1,71 +0,0 @@ -;;; 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 display) - #:use-module (ice-9 format) - #:use-module (click util) - #:export (display-error - display-help)) - - -(define (get-type-description option) - "Return allowed type for the value in the option" - (assoc-ref (option-type option) 'description)) - -(define (display-help procedure option-spec) - (format #t "Usage: ~a [OPTIONS] - - ~a - -Options: -" (program-name) (procedure-documentation procedure)) - - (let* ((options (map (lambda (option) - (cons (format #f - "--~a~a~a" - (car option) - (let ((single-char - (option-property option 'single-char))) - (if single-char - (format #f ", -~a" single-char) - "")) - (let ((value - (not (option-property option 'flag)))) - (if value - (format #f " ~a" (get-type-description option)) - ""))) - (option-property option 'help ""))) - option-spec)) - (sep (+ 2 (apply max (map (lambda (option) - (string-length (car option))) - options))))) - (for-each (lambda (option) - (format #t - " ~a~v_~a~%" - (car option) - (- sep (string-length (car option))) - (cdr option))) - options))) - -(define (display-error wrong-option) - (format #t "Usage: ~a [OPTIONS] -Try '~a --help' for help. - -Error: No such option: ~a -" (program-name) (program-name) wrong-option))