Ver código fonte

v0.3.0

add a `--version` switch and include version number in code
George C. Privon 8 meses atrás
pai
commit
d69425f7e3
2 arquivos alterados com 14 adições e 5 exclusões
  1. 1 1
      CHANGELOG.md
  2. 13 4
      proposal_database.rkt

+ 1 - 1
CHANGELOG.md

@@ -2,7 +2,7 @@
 
 ## v0.3.x
 
-### v0.3.0 (in progress)
+### v0.3.0 (20 April 2025)
 
 - Add option to specify date ranges or limits using `--start-date` and `--end-date`. This applies to `list-*` and `stats` command options.
 - Add `--reuse-parameters`/`-r` for `add`. This will auto-fill the proposal type, submiting organzation, solicitation, and telescope from the most recent submission.

+ 13 - 4
proposal_database.rkt

@@ -9,7 +9,8 @@
          db
          "config.rkt") ; load configuration file
 
-(define progname "proposal_database.rkt")
+(define prog-name "proposal_database.rkt")
+(define prog-version "v0.3.0")
 
 
 ; give us the date in YYYY-MM-DD format
@@ -32,7 +33,7 @@
 
 ; set up command line arguments
 (command-line
- #:program progname
+ #:program prog-name
  #:once-each
  [("-s" "--start-date") sd "Start of date range (YYYY-MM-DD)"
                         (start-date sd)]
@@ -50,7 +51,7 @@
  [("--list-accepted") "Show accepted proposals" (mode "list-accepted")]
  [("--list-rejected") "Show rejected proposals" (mode "list-rejected")]
  [("--list-open-calls") "Show calls that have submitted (but not resolved) proposals" (mode "list-open-calls")]
- #:ps "Copyright 2019-2020, 2022-2025 George Privon")
+ [("-v" "--version") "Print program version information." (mode "version")])
 
 ; set up a condensed prompt for getting information
 (define (getinput prompt)
@@ -58,6 +59,13 @@
   (write-string ": ")
   (read-line))
 
+;priint version information
+(define (print-version)
+  (displayln (string-append prog-name
+                            " ("
+                            prog-version
+                            "). Copyright 2019-2020, 2022-2025 George C. Privon.")))
+
 ; decide whether to use singular or plural "proposal" based on the number of proposals
 (define (proposal-plurals Nprop)
   (cond [(= Nprop 1) "proposal"]
@@ -424,7 +432,8 @@ resultdate TEXT DEFAULT '')")
     [(string=? "list-closed" mode) (printprop conn #:submitted #f)]
     [(string=? "list-accepted" mode) (printprop conn #:submitted #f #:accepted #t)]
     [(string=? "list-rejected" mode) (printprop conn #:submitted #f #:rejected #t)]
-    [else (error-handler (string-append "Unknown mode. Try " progname " help\n\n"))])
+    [(string=? "version" mode) (print-version)]
+    [else (error-handler (string-append "Unknown mode. Try " prog-name " help\n\n"))])
 
   ; close the databse
   (disconnect conn))