diff options
author | Mathieu Lirzin <mthl@gnu.org> | 2016-07-01 14:39:21 +0200 |
---|---|---|
committer | Mathieu Lirzin <mthl@gnu.org> | 2016-07-01 16:00:14 +0200 |
commit | a62624301bc7ffef4996364a208b17cd7f3584bc (patch) | |
tree | a32cf1394c86cf7f21517a86aa789bbd7f5a9260 /src | |
parent | 0f04df269157ee005d7030196780c738c67c5a0a (diff) | |
download | cuirass-a62624301bc7ffef4996364a208b17cd7f3584bc.tar cuirass-a62624301bc7ffef4996364a208b17cd7f3584bc.tar.gz |
base: Add %program-name parameter object.
Diffstat (limited to 'src')
-rw-r--r-- | src/cuirass/base.scm | 21 | ||||
-rw-r--r-- | src/cuirass/ui.scm | 6 |
2 files changed, 22 insertions, 5 deletions
diff --git a/src/cuirass/base.scm b/src/cuirass/base.scm index c7c23e2..63e1b7a 100644 --- a/src/cuirass/base.scm +++ b/src/cuirass/base.scm @@ -1,6 +1,7 @@ ;;;; base.scm - Cuirass base module ;;; ;;; Copyright © 2012, 2016 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org> ;;; ;;; This file is part of Cuirass. ;;; @@ -20,9 +21,23 @@ (define-module (cuirass base) #:use-module (ice-9 format) #:use-module (srfi srfi-19) - #:export (guix-variable - with-directory-excursion - call-with-time-display)) + #:export (;; Procedures. + guix-variable + call-with-time-display + ;; Parameters. + %program-name + ;; Macros. + with-directory-excursion)) + +(define %program-name + ;; Similar in spirit to Gnulib 'progname' module. + (make-parameter "" + (λ (val) + (cond ((not (string? val)) + (scm-error 'wrong-type-arg + "%program-name" "Not a string: ~S" (list #f) #f)) + ((string-rindex val #\/) => (λ (idx) (substring val (1+ idx)))) + (else val))))) (define (guix-variable module name) "Dynamically link variable NAME under Guix module MODULE and return it. diff --git a/src/cuirass/ui.scm b/src/cuirass/ui.scm index d953f8a..d351e4e 100644 --- a/src/cuirass/ui.scm +++ b/src/cuirass/ui.scm @@ -18,13 +18,15 @@ ;;; along with Cuirass. If not, see <http://www.gnu.org/licenses/>. (define-module (cuirass ui) + #:use-module (cuirass base) #:use-module (cuirass config) #:export (show-version show-package-information)) -(define (show-version prog) +(define (show-version) "Display version information for COMMAND." - (simple-format #t "~a (~a) ~a~%" prog %package-name %package-version) + (simple-format #t "~a (~a) ~a~%" + (%program-name) %package-name %package-version) (display "Copyright (C) 2016 the Cuirass authors License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. |