-(define (serve-shell-command command)
- (let-values (((in-port out-port id) (process command)))
- (serve-info-records (string-chomp (read-string #f in-port) "\n"))))
+(define (serve-shell-command command dir-selector config)
+ (with-selector-dir
+ dir-selector config
+ (lambda ()
+ (let-values (((in-port out-port id) (process command)))
+ (serve-info-records (string-chomp (read-string #f in-port) "\n"))))))
+
+(define (serve-expression expression dir-selector config)
+ (with-selector-dir
+ dir-selector config
+ (lambda ()
+ (serve-info-records (conc (eval expression))))))
+
+
+;;; Utility methods
+
+(define (with-current-working-directory directory thunk)
+ (let ((old-wd (current-directory))
+ (result 'none))
+ (change-directory directory)
+ (set! result (thunk))
+ (change-directory old-wd)
+ result))