commander-s/scheme/std-command.scm

61 lines
1.5 KiB
Scheme
Raw Normal View History

(define (standard-command-plugin-completer command args)
#f)
(define (standard-command-plugin-evaluater command args)
(run/strings (,command ,@args)))
(define standard-command-plugin
(make-command-plugin #f
standard-command-plugin-completer
standard-command-plugin-evaluater))
;; some common commands
(define no-completer (lambda args #f))
(register-plugin!
(make-command-plugin "ls"
no-completer
(lambda (command args)
(directory-files))))
(register-plugin!
(make-command-plugin "pwd"
no-completer
(lambda (command args)
(cwd))))
(register-plugin!
(make-command-plugin "cd"
no-completer
(lambda (command args)
2005-05-26 13:39:20 -04:00
(chdir (resolve-file-name (if (null? args)
"~"
(car args))))
(cwd))))
(register-plugin!
(make-command-plugin "setenv"
no-completer
(lambda (command args)
(setenv (car args) (cadr args)))))
(register-plugin!
(make-command-plugin "getenv"
no-completer
(lambda (command args)
(getenv (car args)))))
(register-plugin!
(make-command-plugin "printenv"
no-completer
(lambda (command args)
(env->alist))))
2005-05-26 13:39:20 -04:00
(register-plugin!
(make-command-plugin "exit"
no-completer
(lambda (command args)
(exit (if (null? args)
0
(string->number (car args)))))))