67 lines
1.7 KiB
Racket
67 lines
1.7 KiB
Racket
#lang racket/base
|
|
|
|
(require simple-ini/class
|
|
simple-log
|
|
)
|
|
|
|
(provide cfg-get
|
|
cfg-set!
|
|
dbg-git
|
|
info-git
|
|
err-git
|
|
warn-git
|
|
fatal-git
|
|
sync-log-git
|
|
)
|
|
|
|
(sl-def-log git)
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; Internal state / functions
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
(define ini #f)
|
|
|
|
(define (check-ini)
|
|
(when (eq? ini #f)
|
|
(set! ini (new ini% [file 'git-cli]))))
|
|
|
|
(define mutex (make-semaphore 1))
|
|
|
|
(define-syntax critical
|
|
(syntax-rules ()
|
|
((_ b1 ...)
|
|
(dynamic-wind
|
|
(λ () (semaphore-wait mutex))
|
|
(λ () b1 ...)
|
|
(λ () (semaphore-post mutex)))
|
|
)
|
|
)
|
|
)
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; Provided functions
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
; goal : Store one git-cli configuration value.
|
|
; pre : section and key identify a simple-ini setting.
|
|
; post : value has been persisted.
|
|
; result : The result returned by simple-ini.
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
(define (cfg-set! section key value)
|
|
(critical
|
|
(check-ini)
|
|
(send ini set! section key value)))
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
; goal : Read one git-cli configuration value.
|
|
; pre : section and key identify a simple-ini setting.
|
|
; post : Configuration has not been changed.
|
|
; result : The stored value or default-value.
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
(define (cfg-get section key default-value)
|
|
(critical
|
|
(check-ini)
|
|
(send ini get section key default-value)))
|