From 76091d246a3e4d72526c26af600847991fa583b8 Mon Sep 17 00:00:00 2001
From: Arun Isaac
Date: Wed, 4 Dec 2024 17:20:28 +0000
Subject: bin: Add --version flag.
* ravanan/config.scm.in (%project, %version): New variables.
* Makefile (version): New variable.
(%.scm): Substitute %project and %version too.
* bin/ravanan: Import (ravanan config).
(%options): Add --version.
(print-usage): Document it.
(main): Implement it.
---
Makefile | 3 ++-
bin/ravanan | 13 ++++++++++++-
ravanan/config.scm.in | 10 +++++++++-
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 1eaecfa..0201655 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,7 @@
# along with ravanan. If not, see .
project = ravanan
+version = 0.1.0
GUILD ?= guild
GUILE ?= guile
@@ -47,7 +48,7 @@ godir = $(libdir)/guile/$(guile_effective_version)/site-ccache
all: $(objects) $(config_file)
%.scm: %.scm.in
- $(SED) 's|@NODE@|$(NODE)|' $< > $@
+ $(SED) -e 's|@PROJECT@|$(project)|' -e 's|@VERSION@|$(version)|' -e 's|@NODE@|$(NODE)|' $< > $@
%.go: %.scm $(config_file)
GUILE_AUTO_COMPILE=0 $(GUILD) compile -L . -o $@ $<
diff --git a/bin/ravanan b/bin/ravanan
index f8fcdf8..af33ba0 100755
--- a/bin/ravanan
+++ b/bin/ravanan
@@ -30,6 +30,7 @@ exec guile --no-auto-compile -e main -s "$0" "$@"
(json)
(ravanan batch-system)
(ravanan command-line-tool)
+ (ravanan config)
(ravanan reader)
(ravanan utils)
(ravanan workflow))
@@ -71,7 +72,10 @@ exec guile --no-auto-compile -e main -s "$0" "$@"
result)))
(option (list "help") #f #t
(lambda (opt name arg result)
- (acons 'help #t result)))))
+ (acons 'help #t result)))
+ (option (list "version") #f #f
+ (lambda (opt name arg result)
+ (acons 'version #t result)))))
(define (invalid-option opt name arg result)
(error "Invalid option" name))
@@ -81,6 +85,8 @@ exec guile --no-auto-compile -e main -s "$0" "$@"
"Usage: ~a [OPTIONS] CWL-WORKFLOW INPUTS
Run CWL-WORKFLOW with INPUTS.
+ --version print version and exit
+
--batch-system=BATCH-SYSTEM batch system to run jobs on;
Supported batch systems are single-machine (default) and slurm-api
--scratch=SCRATCH path to scratch area on worker nodes
@@ -131,6 +137,11 @@ files that have the token in the @verbatim{SLURM_JWT=token} format."
(when (assq-ref args 'help)
(print-usage program)
(exit #t))
+ (when (assq-ref args 'version)
+ (format (current-output-port)
+ "~a ~a~%"
+ %project %version)
+ (exit #t))
;; Check for required arguments.
(unless (assq-ref args 'store)
(error "ravanan store not specified"))
diff --git a/ravanan/config.scm.in b/ravanan/config.scm.in
index ed90176..c462749 100644
--- a/ravanan/config.scm.in
+++ b/ravanan/config.scm.in
@@ -17,7 +17,15 @@
;;; along with ravanan. If not, see .
(define-module (ravanan config)
- #:export (%node))
+ #:export (%project
+ %version
+ %node))
+
+(define %project
+ "@PROJECT@")
+
+(define %version
+ "@VERSION@")
(define %node
"@NODE@")
--
cgit v1.2.3