Some refactoring, and implement stat

Add convenience functions run and must to the context module, and remove
the similar functions from connection.

In the connection module, rename %run to connection-run now that that
function has moved to context.
This commit is contained in:
Ray Miller 2025-01-08 18:27:46 +00:00
parent 3153469a2c
commit 93820dc307
Signed by: ray
GPG key ID: 043F786C4CD681B8
5 changed files with 78 additions and 57 deletions

View file

@ -36,19 +36,14 @@
(task "Create test file from string content"
(bind-context-vars
(base-dir)
(install-file (file-name-join* base-dir "foo") #:content "Hello, world!\n")))
(task "Create test file from local source"
(bind-context-vars
(base-dir)
(install-file (file-name-join* base-dir "bar") #:local-src (file-name-join* base-dir "foo")))
#:triggers '(fritz))
(task "Create test file from remote source"
(bind-context-vars
(base-dir)
(install-file (file-name-join* base-dir "baz") #:remote-src (file-name-join* base-dir "bar")))
#:triggers '(frobnicate)))
#:handlers `((frobnicate . ,(handler "Frobnicate" (const #t)))
(fritz . ,(handler "Fritz" (const #t)))
(frotz . ,(handler "Frotz" (const #t))))))
(install-file (file-name-join* base-dir "foo") #:content "Hello, world!\n"))
#:register 'foo)
(task "Get file status"
(bind-context-vars (foo) (fs:stat foo))
#:register 'stat-out
#:triggers '(display-stat)))
#:handlers `((display-stat . ,(handler "Display stat"
(bind-context-vars (foo stat-out) (lambda _ (pk foo stat-out))))))))
(run-play test-play)