about summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2024-12-04 17:20:28 +0000
committerArun Isaac2024-12-04 17:20:28 +0000
commit76091d246a3e4d72526c26af600847991fa583b8 (patch)
tree927415c176dd1491a2adaa8e33799e13ce5b5750
parent9a21bfeff8698e441fcd38cc77c895c5d2e9817d (diff)
downloadravanan-76091d246a3e4d72526c26af600847991fa583b8.tar.gz
ravanan-76091d246a3e4d72526c26af600847991fa583b8.tar.lz
ravanan-76091d246a3e4d72526c26af600847991fa583b8.zip
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.
-rw-r--r--Makefile3
-rwxr-xr-xbin/ravanan13
-rw-r--r--ravanan/config.scm.in10
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 <https://www.gnu.org/licenses/>.
 
 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 <https://www.gnu.org/licenses/>.
 
 (define-module (ravanan config)
-  #:export (%node))
+  #:export (%project
+            %version
+            %node))
+
+(define %project
+  "@PROJECT@")
+
+(define %version
+  "@VERSION@")
 
 (define %node
   "@NODE@")