From e57e297af60bd50230a27305ea42a34210a109ca Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 17 Aug 2016 20:41:36 -0400 Subject: cli: Add --version flag. * sly/config.scm.in (%sly-version): New variable. --- sly/cli.scm | 15 +++++++++++++++ sly/config.scm.in | 3 +++ 2 files changed, 18 insertions(+) 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))))) @@ -84,10 +89,20 @@ (define (show-help) (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 +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)) -- cgit v1.2.3