Initial import of rash-git-cli
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#lang racket/base
|
||||
|
||||
(require (except-in git-cli git)
|
||||
(only-in git-cli [git git/procedure])
|
||||
(for-syntax racket/base
|
||||
syntax/parse
|
||||
linea/line-macro-prop))
|
||||
|
||||
(provide (except-out (all-from-out git-cli) git/procedure)
|
||||
git)
|
||||
|
||||
;; `git` remains the ordinary git-cli procedure in Racket expression mode.
|
||||
;; In Linea/Rash line mode, bare command words are quoted and passed to that
|
||||
;; same procedure.
|
||||
(begin-for-syntax
|
||||
(define (git-argument->expression stx)
|
||||
(syntax-parse stx
|
||||
[(quote value)
|
||||
stx]
|
||||
[id:id
|
||||
#`(quote #,(syntax-e #'id))]
|
||||
[_
|
||||
stx]))
|
||||
|
||||
(struct git-line-binding (target)
|
||||
#:property prop:procedure
|
||||
(λ (self stx)
|
||||
(syntax-parse stx
|
||||
[id:id
|
||||
(git-line-binding-target self)]
|
||||
[(id argument ...)
|
||||
#`(#,(git-line-binding-target self) argument ...)]))
|
||||
#:property prop:line-macro
|
||||
(λ (self stx)
|
||||
(syntax-parse stx
|
||||
[(_ argument ...)
|
||||
(define arguments
|
||||
(map git-argument->expression
|
||||
(syntax->list #'(argument ...))))
|
||||
#`(#,(git-line-binding-target self) #,@arguments)]))))
|
||||
|
||||
(define-syntax git
|
||||
(git-line-binding #'git/procedure))
|
||||
Reference in New Issue
Block a user