aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cuirass/base.scm21
-rw-r--r--src/cuirass/ui.scm6
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.