use util.lisp more

This commit is contained in:
SANO Masatoshi 2016-01-14 12:00:14 +09:00
parent 49b8e52ede
commit e8e8fe6f66
3 changed files with 40 additions and 34 deletions

View file

@ -15,19 +15,14 @@ exec ros +Q -m roswell -L sbcl-bin -- $0 "$@"
#-ros.sub.list
(defpackage :ros.sub.list
(:use :cl))
(in-package :ros.sub.list)
#-ros.sub.list
(ros:quicklisp :environment nil)
#-ros.sub.list
(unless (find-package :uiop)
(ql:quickload :uiop :silent t))
#-ros.sub.list
(unless (find-package :net.html.parser)
(ql:quickload :cl-html-parse :silent t))
#-ros.sub.list
(defun impl (imp)
(ros:roswell `(,(format nil "roswell-internal-use impl ~A" (or imp ""))) :string t))
#-ros.sub.list
(defun list-impls (impl &key function params)
(declare (ignorable params))
@ -40,6 +35,7 @@ exec ros +Q -m roswell -L sbcl-bin -- $0 "$@"
:type :wild))))
(mapcar function
dir)))
#-ros.sub.list
(progn
(export

View file

@ -5,36 +5,24 @@ exec ros +R +Q -L sbcl-bin -m roswell -- $0 "$@"
|#
(cl:in-package :cl-user)
#-ros.util
(load (make-pathname
:defaults *load-pathname*
:name "util" :type "lisp"))
(when (cl:find-package :ros.use)
(push :ros.use *features*))
#-ros.use
(defpackage :ros.use
(:use :cl))
(:use :cl :ros.util))
(in-package :ros.use)
#-ros.use
(defun config (&rest argv)
(ros:roswell `("config" "set" ,@argv) :string t))
#-ros.use
(defun main (subcmd impl/version &rest argv)
(declare (ignore subcmd impl/version))
(if (and argv
(ignore-errors
(ros:roswell `("-L" ,(first argv) "version=t" "run"))))
(let* ((pos (position #\/ (first argv)))
(lisp (if pos
(subseq (first argv) 0 pos)
(first argv))))
(if pos
(progn
(config "default.lisp" lisp)
(config (format nil "~A.version" lisp)
(subseq (first argv) (1+ pos))))
(config (if (digit-char-p (aref lisp 0))
(format nil "~A.version" (ros:roswell `("config" "show" "default.lisp") :string t))
"default.lisp")
lisp)))
(progn
(format *error-output* "Error to use '~A'~%" (first argv))
(ros:quit 1))))
(unless (use (first argv))
(format *error-output* "Error to use '~A'~%" (first argv))
(ros:quit 1)))

View file

@ -4,22 +4,44 @@
(defpackage :ros.util
(:use :cl)
(:export :uname :uname-m :homedir :config))
(:export :uname :uname-m :homedir :config :use :impl))
(in-package :ros.util)
(defun uname ()
(ros:roswell '("roswell-internal-use uname") :string t))
(ros:roswell '("roswell-internal-use" "uname") :string t))
(defun uname-m ()
(ros:roswell '("roswell-internal-use uname -m") :string t))
(ros:roswell '("roswell-internal-use" "uname" "-m") :string t))
(defun homedir ()
(ros:opt "homedir"))
(defun impl (imp)
(ros:roswell `("roswell-internal-use" "impl" ,(or imp "")) :string t))
(defun config (c)
(ros:roswell (list "config show" c) :string t))
(defun (setf config) (a b)
(ros:roswell (list "config" b a) :string t)
a)
(defun use (arg)
(when (and arg
(ignore-errors
(ros:roswell `("-L" ,arg "version=t" "run"))))
(let* ((pos (position #\/ arg))
(lisp (if pos
(subseq arg 0 pos)
arg)))
(if pos
(progn
(config "default.lisp" lisp)
(config (format nil "~A.version" lisp)
(subseq arg (1+ pos))))
(config (if (digit-char-p (aref lisp 0))
(format nil "~A.version" (config "default.lisp"))
"default.lisp")
lisp)))
t))