mirror of
https://github.com/roswell/roswell.git
synced 2026-09-10 07:16:17 -04:00
tidy
This commit is contained in:
parent
239ae4749e
commit
557b061f25
|
|
@ -67,8 +67,8 @@ exec ros -Q -m roswell -L sbcl-bin -- $0 "$@"
|
|||
(let ((s *error-output*))
|
||||
(format s "Usage: ~A asdf install/use/list/delete version ~%" (ros:opt "wargv0"))))
|
||||
|
||||
(defun main (? asdf &optional subcmd &rest argv)
|
||||
(declare (ignorable ? asdf argv))
|
||||
(defun main (cmd &optional subcmd &rest argv)
|
||||
(declare (ignore cmd))
|
||||
(if subcmd
|
||||
(let ((fun (cdr (assoc subcmd *subcommands* :test 'equal))))
|
||||
(apply fun argv))
|
||||
|
|
|
|||
|
|
@ -27,11 +27,9 @@ exec ros -Q +R -- $0 "$@"
|
|||
(format *error-output* "~&Usage: ~A build <file>~%"
|
||||
(ros:opt "argv0")))
|
||||
|
||||
(defun main (&rest argv)
|
||||
(unless argv
|
||||
(help)
|
||||
(ros:quit))
|
||||
(let ((file (third argv))
|
||||
(defun main (cmd &rest argv)
|
||||
(declare (ignore cmd))
|
||||
(let ((file (first argv))
|
||||
exec)
|
||||
(unless file
|
||||
(help)
|
||||
|
|
@ -43,6 +41,6 @@ exec ros -Q +R -- $0 "$@"
|
|||
for line = (read-line in)
|
||||
when (ignore-errors (string= line "exec" :end1 4))
|
||||
do (setf exec (parse-argv line))))
|
||||
(ros:roswell `(,exec "dump" "executable" ,@(cddr argv))
|
||||
(ros:roswell `(,exec "dump" "executable" ,@argv)
|
||||
:interactive nil)))
|
||||
;;; vim: set ft=lisp lisp:
|
||||
|
|
|
|||
|
|
@ -41,26 +41,26 @@ exec ros +Q -m roswell -L sbcl-bin -- $0 "$@"
|
|||
(cons (list var "0" val)
|
||||
config))))
|
||||
|
||||
(defun main (&rest argv)
|
||||
(declare (ignorable argv))
|
||||
(defun main (cmd &rest argv)
|
||||
(declare (ignore cmd))
|
||||
(let* ((path (merge-pathnames "config" (ros.util:version "confdir")))
|
||||
(conf (load-config path))
|
||||
(len (length argv)))
|
||||
(cond
|
||||
((= 2 len)
|
||||
((= 0 len)
|
||||
(loop for i in conf
|
||||
do (format *error-output* "~A=~A~%" (first i) (third i))
|
||||
finally (format *error-output* "~%Possible subcommands:~%set~%show~%")) 0)
|
||||
((= 3 len)
|
||||
(setf conf (unconfig conf (third argv)))
|
||||
((= 1 len)
|
||||
(setf conf (unconfig conf (first argv)))
|
||||
(save-config path conf) 0)
|
||||
((and (equal (third argv) "set") (= 5 len))
|
||||
(setf conf (config conf (fourth argv) (fifth argv)))
|
||||
((and (equal (first argv) "set") (= 3 len))
|
||||
(setf conf (config conf (second argv) (third argv)))
|
||||
(save-config path conf) 0)
|
||||
((and (equal (third argv) "show") (= 4 len))
|
||||
(format t "~A~%" (third (find (fourth argv) conf :test 'equal :key #'first))) 0)
|
||||
((= 4 len)
|
||||
(setf conf (config conf (third argv) (fourth argv)))
|
||||
((and (equal (first argv) "show") (= 2 len))
|
||||
(format t "~A~%" (third (find (second argv) conf :test 'equal :key #'first))) 0)
|
||||
((= 2 len)
|
||||
(setf conf (config conf (first argv) (second argv)))
|
||||
(save-config path conf) 0)
|
||||
(t 1))))
|
||||
;;; vim: set ft=lisp lisp:
|
||||
|
|
|
|||
|
|
@ -32,12 +32,11 @@ exec ros +Q -m roswell -L sbcl-bin -- $0 "$@"
|
|||
(delete-file path)
|
||||
(format *error-output* "The specified image doesn't exist \"~A ~A\"~%" name impl))))
|
||||
|
||||
(defun main (subcmd cmd &rest r)
|
||||
(defun main (cmd &rest r)
|
||||
(declare (ignore cmd))
|
||||
(let* ((default (config "default.lisp"))
|
||||
(verstring (format nil "~A.version" default))
|
||||
(config (format nil "~A/~A" default (config verstring))))
|
||||
;; (print (list subcmd cmd r default verstring config))
|
||||
(cond
|
||||
((null r)
|
||||
(format *error-output* "Usage: ros delete dump [IMAGES...]~%")
|
||||
|
|
@ -49,8 +48,6 @@ exec ros +Q -m roswell -L sbcl-bin -- $0 "$@"
|
|||
(format *error-output* "~%Possible candidates of installed impls for deletion:~2%")
|
||||
(finish-output *error-output*)
|
||||
(ros:roswell '("list" "installed") *standard-output*))
|
||||
((not (equal subcmd "main"))
|
||||
(error "what is this?"))
|
||||
((equal (first r) "dump")
|
||||
(delete-dump (rest r)))
|
||||
(t
|
||||
|
|
|
|||
|
|
@ -92,11 +92,11 @@ exec ros -- $0 "$@"
|
|||
#+(or sbcl ccl)
|
||||
("executable" dump-executable)))
|
||||
|
||||
(defun main (subcmd cmd &rest r)
|
||||
(cond ((and (equal subcmd "main") r)
|
||||
(let ((func (second (assoc (first r) *subcmds* :test 'equal))))
|
||||
(if func
|
||||
(funcall func (rest r))
|
||||
(format *error-output* "'~A' is not a valid command for '~A' subcommand~%" (first r) cmd))))
|
||||
(t (format t "~{~a~%~}" (mapcar #'car *subcmds*)))))
|
||||
(defun main (cmd &rest r)
|
||||
(if r
|
||||
(let ((func (second (assoc (first r) *subcmds* :test 'equal))))
|
||||
(if func
|
||||
(funcall func (rest r))
|
||||
(format *error-output* "'~A' is not a valid command for '~A' subcommand~%" (first r) cmd)))
|
||||
(format t "~{~a~%~}" (mapcar #'car *subcmds*))))
|
||||
;;; vim: set ft=lisp lisp:
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ exec ros -L sbcl-bin -- $0 "$@"
|
|||
(:use :cl))
|
||||
(in-package :ros.script.emacs.3672012160)
|
||||
|
||||
(defvar *verbose-p* (string= "1" (ros:opt "verbose")))
|
||||
(defvar *verbose-p* nil)
|
||||
|
||||
(defmacro mute-error-if-not-verbose (&body body)
|
||||
"Execute the body, catches (and hide) any error if *verbose-p* is nil."
|
||||
|
|
@ -21,16 +21,15 @@ exec ros -L sbcl-bin -- $0 "$@"
|
|||
(error condition)
|
||||
(values nil condition)))))
|
||||
|
||||
(defun main (&rest argv)
|
||||
(let ((path (merge-pathnames "slime-helper.el" (ros:opt "quicklisp"))))
|
||||
(defun main (cmd &rest argv)
|
||||
(declare (ignore cmd))
|
||||
(let ((path (merge-pathnames "slime-helper.el" (ros:opt "quicklisp")))
|
||||
(*verbose-p* (or (ros:verbose)
|
||||
(ros:opt "emacs.verbose"))))
|
||||
(unless (probe-file path)
|
||||
(ros:roswell '("-L" "sbcl-bin" "-s" "quicklisp-slime-helper" "-q") :interactive nil))
|
||||
;; This enable to set verbosity only for this file (instead of whole roswell).
|
||||
(when (and (= 3 (length argv))
|
||||
(string= "--verbose" (third argv)))
|
||||
(setf *verbose-p* t))
|
||||
(mute-error-if-not-verbose
|
||||
(ros:exec
|
||||
`("emacs" "-l" ,(namestring path) "--eval"
|
||||
"(setq inferior-lisp-program \"ros -Q run\")" ,@(cddr argv))))))
|
||||
`("emacs" "-l" ,(namestring path) "--eval"
|
||||
"(setq inferior-lisp-program \"ros -Q run\")" ,@argv)))))
|
||||
;;; vim: set ft=lisp lisp:
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ exec ros -Q -m roswell -L sbcl-bin -- $0 "$@"
|
|||
(:use :cl))
|
||||
(in-package :ros.script.fmt.3665046980)
|
||||
|
||||
(defun main (&rest argv)
|
||||
(defun main (cmd &rest argv)
|
||||
"go fmt like something it should be implemented in common lisp"
|
||||
(declare (ignorable argv))
|
||||
(declare (ignore cmd argv))
|
||||
(loop for file in (append (directory "*.lisp")
|
||||
(directory "*.ros"))
|
||||
do (ros:roswell `("emacs" "-Q" "-q" "--batch"
|
||||
|
|
|
|||
|
|
@ -79,25 +79,26 @@ exec ros -Q -m roswell -L sbcl-bin -- $0 "$@"
|
|||
(command stream i max))
|
||||
(format stream "~%")))
|
||||
|
||||
(defun main (&rest argv)
|
||||
(defun main (cmd &rest argv)
|
||||
(declare (ignore cmd))
|
||||
(let ((s *error-output*))
|
||||
(cond
|
||||
((not (third argv)) ;; without any options
|
||||
((not (first argv)) ;; without any options
|
||||
(format s "Usage: ~A [OPTIONS] [Command arguments...]~%" (ros:opt "wargv0"))
|
||||
(format s "Usage: ~A [OPTIONS] [[--] script-path arguments...]~%~%" (ros:opt "wargv0"))
|
||||
(commands s)
|
||||
(option s))
|
||||
((equal (third argv) "run")
|
||||
((equal (first argv) "run")
|
||||
(format s "Usage: ~A [OPTIONS] run [OPTIONS] [-- implementation-native-options...]~%~%" (ros:opt "wargv0"))
|
||||
(option s (nthcdr 4 *options*))) ;; fix me
|
||||
((equal (third argv) "install")
|
||||
((equal (first argv) "install")
|
||||
(let ((path (ros:opt "quicklisp")))
|
||||
(unless (probe-file (merge-pathnames "setup.lisp" path))
|
||||
(ros:roswell '("install" "quicklisp"))))
|
||||
(ros:quicklisp :environment nil)
|
||||
(ros:include "util-install")
|
||||
(ros:include "util-install-quicklisp")
|
||||
(if (not (fourth argv))
|
||||
(if (not (second argv))
|
||||
(progn
|
||||
(format s "Usage: ~A install impl [OPTIONS]~2%" (ros:opt "wargv0"))
|
||||
(format s "For more details on impl specific options, type:~%")
|
||||
|
|
@ -108,8 +109,8 @@ exec ros -Q -m roswell -L sbcl-bin -- $0 "$@"
|
|||
when (and (string-equal "roswell.install." i :end2 (min (length i) len))
|
||||
(not (eql (aref i (1- (length i))) #\+)))
|
||||
do (format s "~A~%" (subseq i len))))
|
||||
(let ((impl (fourth argv)))
|
||||
(let ((impl (second argv)))
|
||||
(ql:quickload (format nil "roswell.install.~A" impl) :silent t)
|
||||
(funcall (read-from-string"ros.install::install-impl") impl nil "help" nil))))
|
||||
(t (ros:exec `("man" ,(format nil "ros-~A" (third argv))))))))
|
||||
(t (ros:exec `("man" ,(format nil "ros-~A" (first argv))))))))
|
||||
;;; vim: set ft=lisp lisp:
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ exec ros -Q -m roswell -L sbcl-bin -- $0 "$@"
|
|||
(:use :cl :ros))
|
||||
(in-package :ros.script.init.3672012201)
|
||||
|
||||
(defun main (subcmd cmd &optional name &rest r)
|
||||
(defun main (cmd &optional name &rest r)
|
||||
(declare (ignore cmd))
|
||||
(if (and (equal subcmd "main") name)
|
||||
(if name
|
||||
(let* ((date (get-universal-time))
|
||||
(path
|
||||
(or (probe-file (merge-pathnames (format nil "templates/~A/template.asd" name) (ros.util:homedir)))
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ exec ros -Q +R -L sbcl-bin -- $0 "$@"
|
|||
|
||||
(in-package :ros.script.install.3671936092)
|
||||
|
||||
(defun main (subcmd impl/version &rest argv)
|
||||
(defun main (cmd impl/version &rest argv)
|
||||
(declare (ignore cmd))
|
||||
(let* (imp
|
||||
(pos (position #\/ impl/version))
|
||||
(*ros-path* (make-pathname :defaults (ros:opt "argv0")))
|
||||
|
|
@ -25,7 +26,7 @@ exec ros -Q +R -L sbcl-bin -- $0 "$@"
|
|||
imp (subseq impl/version 0 pos))
|
||||
(setq imp impl/version))
|
||||
(read-call "quicklisp-client:register-local-projects")
|
||||
(cond ((install-impl-if-probed imp version subcmd argv))
|
||||
(cond ((install-impl-if-probed imp version argv))
|
||||
((install-script-if-probed impl/version))
|
||||
((install-system-if-probed imp))
|
||||
(version
|
||||
|
|
@ -33,7 +34,7 @@ exec ros -Q +R -L sbcl-bin -- $0 "$@"
|
|||
(format *error-output* "install from github ~A/~A~%" imp version)
|
||||
(clone-github imp version :path "local-projects")
|
||||
(read-call "quicklisp-client:register-local-projects")
|
||||
(or (install-impl-if-probed version nil subcmd argv)
|
||||
(or (install-impl-if-probed version nil argv)
|
||||
(install-system-if-probed version)))
|
||||
(t (format *error-output* "'~A' is not a valid target for 'install' -- It should be a name of either:
|
||||
+ a quicklisp-installable system
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ exec ros +Q -m roswell -L sbcl-bin -- $0 "$@"
|
|||
(dolist (v (funcall cmd))
|
||||
(format t "~A~%" v))))))))
|
||||
|
||||
(defun main (subcmd cmd &rest r)
|
||||
(declare (ignorable subcmd cmd))
|
||||
(defun main (cmd &rest r)
|
||||
(declare (ignore cmd))
|
||||
(if (null r)
|
||||
(progn
|
||||
(format *error-output* "Possible subcommands:~%")
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ exec ros -Q -L sbcl-bin -- $0 "$@"
|
|||
until (eql i end)
|
||||
always (member (first i) '(defun defvar defparameter quote)))))))))
|
||||
|
||||
(defun main (method subcmd &optional (dump "roswell") &rest argv)
|
||||
(declare (ignorable argv method subcmd))
|
||||
(defun main (cmd &optional (dump "roswell") &rest argv)
|
||||
(declare (ignore cmd argv))
|
||||
#-win32
|
||||
(ignore-errors
|
||||
(require :sb-posix)
|
||||
|
|
|
|||
|
|
@ -106,8 +106,8 @@ exec ros -Q -m roswell -L sbcl-bin -- $0 "$@"
|
|||
(dolist (i (swank-get-version))
|
||||
(format t "~A~%" i)))
|
||||
|
||||
(defun main (method command &optional sub &rest argv)
|
||||
(declare (ignorable argv method command))
|
||||
(defun main (cmd &optional sub &rest argv)
|
||||
(declare (ignore cmd))
|
||||
(let ((func (cdr (assoc sub *sub* :test #'equal))))
|
||||
(when func
|
||||
(ros:quit (apply func argv))))
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ exec ros -Q -m roswell -L sbcl-bin -- $0 "$@"
|
|||
(format *error-output* "~&~15A ~A" command (documentation func 'function))))
|
||||
|
||||
|
||||
(defun main (method command &optional sub &rest argv)
|
||||
(declare (ignorable method command))
|
||||
(defun main (cmd &optional sub &rest argv)
|
||||
(declare (ignore cmd))
|
||||
(let ((func (cdr (assoc sub *subcommands* :test #'equal))))
|
||||
(if func
|
||||
(funcall func argv)
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ exec ros +R +Q -L sbcl-bin -m roswell -- $0 "$@"
|
|||
|
||||
(in-package :ros.script.use.3672012320)
|
||||
|
||||
(defun main (subcmd impl/version &rest argv)
|
||||
(declare (ignorable subcmd impl/version))
|
||||
(defun main (cmd &rest argv)
|
||||
(declare (ignore cmd))
|
||||
(if (null argv)
|
||||
(progn
|
||||
(format *error-output* "Possible target candidates:~%")
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
(in-package :ros.install)
|
||||
|
||||
(defvar *ros-path* nil)
|
||||
(defvar *help-cmds* nil)
|
||||
(defvar *install-cmds* nil)
|
||||
(defvar *list-cmd* nil)
|
||||
|
||||
|
|
@ -34,10 +33,8 @@
|
|||
(find impl '("sbcl-bin" "quicklisp") :test 'equal)
|
||||
(load (make-pathname :name (format nil "install-~A" impl) :type "lisp" :defaults *load-pathname*)))))
|
||||
|
||||
(defun install-impl (impl version subcmd argv)
|
||||
(let ((cmds (cond
|
||||
((equal subcmd "install") (cdr (assoc impl *install-cmds* :test #'equal)))
|
||||
((equal subcmd "help") (cdr (assoc impl *help-cmds* :test #'equal))))))
|
||||
(defun install-impl (impl version argv)
|
||||
(let ((cmds (cdr (assoc impl *install-cmds* :test #'equal))))
|
||||
(when cmds
|
||||
(let ((param `(t :target ,impl :version ,version :argv ,argv)))
|
||||
(handler-case
|
||||
|
|
@ -50,10 +47,10 @@
|
|||
(format t "SIGINT detected, cleaning up the partially installed files~%")
|
||||
(ros:roswell `(,(format nil "deleteing ~A/~A" (getf (cdr param) :target) (getf (cdr param) :version))) :string t)))))))
|
||||
|
||||
(defun install-impl-if-probed (imp version subcmd argv)
|
||||
(defun install-impl-if-probed (imp version argv)
|
||||
(let ((result (probe-impl imp)))
|
||||
(when result
|
||||
(install-impl imp version subcmd argv)
|
||||
(install-impl imp version argv)
|
||||
result)))
|
||||
|
||||
(defun install-script-if-probed (impl/version)
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ exec ros -Q -m roswell -L sbcl-bin -- $0 "$@"
|
|||
(:use :cl :ros.util))
|
||||
(in-package :ros.script.version.3668210994)
|
||||
|
||||
(defun main (&rest argv)
|
||||
(declare (ignorable argv))
|
||||
(defun main (cmd &rest argv)
|
||||
(declare (ignore cmd argv))
|
||||
(let ((revision (version "revision"))
|
||||
(curl (version "curl"))
|
||||
(asdf (version "asdf"))
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ exec ros -Q -- $0 "$@"
|
|||
(:use :cl))
|
||||
(in-package :ros.script.wait.3672012352)
|
||||
|
||||
(defun main (&rest argv)
|
||||
(declare (ignorable argv))
|
||||
(defun main (cmd &rest argv)
|
||||
(declare (ignore cmd argv))
|
||||
(loop (sleep 1)))
|
||||
;;; vim: set ft=lisp lisp:
|
||||
|
|
|
|||
15
src/ros.c
15
src/ros.c
|
|
@ -19,14 +19,13 @@ LVal top_options;
|
|||
|
||||
int proccmd(int argc,char** argv,LVal option,LVal command);
|
||||
|
||||
int proccmd_with_subcmd(char* path,char* subcmd,int argc,char** argv,LVal option,LVal command) {
|
||||
char** argv2=(char**)alloc(sizeof(char*)*(argc+2));
|
||||
int proccmd_with_subcmd(char* path,int argc,char** argv,LVal option,LVal command) {
|
||||
char** argv2=(char**)alloc(sizeof(char*)*(argc+1));
|
||||
int i,ret;
|
||||
for(i=0;i<argc;++i)
|
||||
argv2[i+2]=argv[i];
|
||||
argv2[i+1]=argv[i];
|
||||
argv2[0]=path;
|
||||
argv2[1]=subcmd;
|
||||
ret=proccmd(argc+2,argv2,option,command);
|
||||
ret=proccmd(argc+1,argv2,option,command);
|
||||
dealloc(argv2);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -116,17 +115,17 @@ int proccmd(int argc,char** argv,LVal option,LVal command) {
|
|||
char* cmddir=configdir();
|
||||
char* cmdpath=cat(cmddir,argv[0],".ros",NULL);
|
||||
if(directory_exist_p(cmddir) && file_exist_p(cmdpath))
|
||||
proccmd_with_subcmd(cmdpath,"main",argc,argv,top_options,top_commands);
|
||||
proccmd_with_subcmd(cmdpath,argc,argv,top_options,top_commands);
|
||||
s(cmddir),s(cmdpath);
|
||||
/* systemwide commands*/
|
||||
cmddir=subcmddir();
|
||||
cmdpath=cat(cmddir,argv[0],".ros",NULL);
|
||||
if(directory_exist_p(cmddir)) {
|
||||
if(file_exist_p(cmdpath))
|
||||
proccmd_with_subcmd(cmdpath,"main",argc,argv,top_options,top_commands);
|
||||
proccmd_with_subcmd(cmdpath,argc,argv,top_options,top_commands);
|
||||
s(cmdpath);cmdpath=cat(cmddir,"+",argv[0],".ros",NULL);
|
||||
if(file_exist_p(cmdpath))
|
||||
proccmd_with_subcmd(cmdpath,"main",argc,argv,top_options,top_commands);
|
||||
proccmd_with_subcmd(cmdpath,argc,argv,top_options,top_commands);
|
||||
}
|
||||
s(cmddir),s(cmdpath);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ int mklockdir(char* path);
|
|||
int lock_apply(char* symbol,int remove);
|
||||
|
||||
int proccmd(int argc,char** argv,LVal option,LVal command);
|
||||
int proccmd_with_subcmd(char* path,char* subcmd,int argc,char** argv,LVal option,LVal command);
|
||||
int proccmd_with_subcmd(char* path,int argc,char** argv,LVal option,LVal command);
|
||||
|
||||
char* sbcl_bin(char* file);
|
||||
char* ccl_binname(char* bit);
|
||||
|
|
|
|||
Loading…
Reference in a new issue