2005-09-27 12:18:04 -04:00
|
|
|
(define command-prefix #\,)
|
|
|
|
|
|
|
|
(define (split-scheme-command-line command-line)
|
|
|
|
(let ((tokens (string-tokenize command-line)))
|
2005-09-27 12:33:03 -04:00
|
|
|
(values (string-drop (car tokens) 1)
|
2005-09-27 12:18:04 -04:00
|
|
|
(cdr tokens))))
|
|
|
|
|
|
|
|
(define (scheme-command-line? command-line)
|
|
|
|
(char=? (string-ref (string-trim command-line) 0)
|
|
|
|
command-prefix))
|
|
|
|
|
|
|
|
(define (eval-scheme-command command args)
|
2005-09-27 12:33:03 -04:00
|
|
|
(case (string->symbol command)
|
|
|
|
((in)
|
2005-09-27 12:18:04 -04:00
|
|
|
(set-evaluation-package! (string->symbol (car args)))
|
|
|
|
(string-append "moved to package " (car args)))
|
|
|
|
((open)
|
|
|
|
(package-open!
|
|
|
|
(evaluation-environment)
|
|
|
|
(lambda ()
|
|
|
|
(environment-ref
|
|
|
|
(config-package) (string->symbol (car args)))))
|
|
|
|
(string-append "opened package " (car args)))
|
|
|
|
((user)
|
|
|
|
(set-evaluation-package! 'nuit-eval)
|
|
|
|
"moved to package nuit-eval")
|
2005-09-27 12:33:03 -04:00
|
|
|
((inspect)
|
|
|
|
(if (null? args)
|
|
|
|
",inspect requires an argument"
|
|
|
|
(make-inspection-object
|
|
|
|
(eval-string (string-join args)))))
|
2005-09-27 12:35:49 -04:00
|
|
|
((reload-package)
|
|
|
|
(if (null? args)
|
|
|
|
",reload-package requires an argument"
|
|
|
|
(let ((s (get-structure (string->symbol (car args)))))
|
|
|
|
(if (not (package-unstable? (structure-package s)))
|
|
|
|
"read-only structure"
|
|
|
|
(begin
|
|
|
|
(set-package-loaded?! (structure-package s) #f)
|
|
|
|
(ensure-loaded s)
|
|
|
|
"reloaded package")))))
|
2005-09-27 12:33:03 -04:00
|
|
|
((exit)
|
|
|
|
(exit))
|
|
|
|
(else (error "unknwon scheme command" command))))
|