Merge branch wip/interceptors into main
This commit is contained in:
parent
06c2679c64
commit
9faaeab2b0
32 changed files with 680 additions and 471 deletions
|
@ -2,5 +2,4 @@
|
|||
|
||||
MODULES_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/../modules" &> /dev/null && pwd )
|
||||
|
||||
# guile -L modules --no-auto-compile -e '(@ (ordo cli) main)' -- $PWD/examples/inventory.scm $PWD/examples/basic.scm
|
||||
exec guile -L "${MODULES_DIR}" --no-auto-compile -e '(@ (ordo cli) main)' -- "$@"
|
||||
|
|
43
bin/play.scm
43
bin/play.scm
|
@ -1,43 +0,0 @@
|
|||
#!/usr/bin/env -S guile --no-auto-compile -e main -s
|
||||
!#
|
||||
(use-modules (srfi srfi-11)
|
||||
(ice-9 getopt-long)
|
||||
(ice-9 format)
|
||||
(ordo util filesystem))
|
||||
|
||||
(define (tar . args)
|
||||
(unless (zero? (apply system* "tar" args))
|
||||
(error (format #f "Non-zero exit from tar ~a" args))))
|
||||
|
||||
(define* (usage #:optional errmsg)
|
||||
(with-output-to-port (current-error-port)
|
||||
(lambda ()
|
||||
(when errmsg
|
||||
(format #t "Error: ~a~%~%" errmsg))
|
||||
(display "Usage: play -t TARGET PLAYBOOK")
|
||||
(newline)))
|
||||
(exit (if errmsg EXIT_FAILURE EXIT_SUCCESS)))
|
||||
|
||||
(define (process-options args)
|
||||
(let* ((option-spec '((help (single-char #\h) (value #f))
|
||||
(target (single-char #\t) (value #t) (required? #t))))
|
||||
(options (getopt-long args option-spec))
|
||||
(help-wanted (option-ref options 'help #f))
|
||||
(target (option-ref options 'target #f))
|
||||
(args (option-ref options '() '())))
|
||||
(cond
|
||||
(help-wanted (usage))
|
||||
((not (= 1 (length args)))
|
||||
(usage "Expected exactly one playbook")))
|
||||
(values (canonicalize-path (car args)) target)))
|
||||
|
||||
(define (main args)
|
||||
(let-values (((playbook-path target) (process-options args)))
|
||||
(define playbook (load playbook-path))
|
||||
(define top-dir (dirname (dirname (current-filename))))
|
||||
(call-with-temporary-directory
|
||||
(lambda (tmp-dir)
|
||||
(define tarball (string-append tmp-dir "/payload.tar"))
|
||||
(tar "--create" "--file" tarball "--directory" top-dir "modules" "bin")
|
||||
(tar "--append" "--file" tarball "--transform" "s/.*/playbook.scm/" playbook-path)
|
||||
(tar "tf" tarball)))))
|
Loading…
Add table
Add a link
Reference in a new issue