summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2016-08-17 20:41:36 -0400
committerDavid Thompson <dthompson2@worcester.edu>2016-08-17 20:48:56 -0400
commite57e297af60bd50230a27305ea42a34210a109ca (patch)
treebd248f2ff88207c687f2edf4bdf5867339354f1a
parentf2f7778d36d266ba308f410b83f9eb67e2692c73 (diff)
cli: Add --version flag.
* sly/config.scm.in (%sly-version): New variable.
-rw-r--r--sly/cli.scm15
-rw-r--r--sly/config.scm.in3
2 files changed, 18 insertions, 0 deletions
diff --git a/sly/cli.scm b/sly/cli.scm
index b4040d0..49b5070 100644
--- a/sly/cli.scm
+++ b/sly/cli.scm
@@ -19,6 +19,7 @@
#:use-module (ice-9 format)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-37)
+ #:use-module (sly config)
#:use-module (sly game)
#:use-module (sly input keyboard)
#:use-module (sly repl)
@@ -77,6 +78,10 @@
(lambda _
(show-help)
(exit 0)))
+ (option '(#\V "version") #f #f
+ (lambda _
+ (show-version)
+ (exit 0)))
(option '(#\d "develop") #f #f
(lambda (opt name arg result)
(alist-cons 'develop? #t result)))))
@@ -85,9 +90,19 @@
(display "Usage: sly [OPTION]... GAME-DIRECTORY
Run the Sly game located in GAME-DIRECTORY.\n")
(display "
+ -v, --version Display version information")
+ (display "
-d, --develop Run in development mode")
(newline))
+(define (show-version)
+ (format #t "sly ~a~%" %sly-version)
+ (display "Copyright (C) 2016 the Sly 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.
+There is NO WARRANTY, to the extent permitted by law.")
+ (newline))
+
(define (sly-main args)
(let* ((opts (args-fold args
%options
diff --git a/sly/config.scm.in b/sly/config.scm.in
index 46f8bfe..cd70d63 100644
--- a/sly/config.scm.in
+++ b/sly/config.scm.in
@@ -23,11 +23,14 @@
(define-module (sly config)
#:export (%datadir
+ %sly-version
scope-datadir))
(define %datadir
(or (getenv "SLY_DATADIR") "@sly_datadir@/sly"))
+(define %sly-version "@PACKAGE_VERSION@")
+
(define (scope-datadir file)
"Append the Sly data directory to FILE."
(string-append %datadir file))