changeset 570: |
d1c75054df03 |
parent: |
32995daa9a07
|
child: |
35bb0d5ec95e |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Tue, 30 Jul 2024 21:54:16 -0400 |
permissions: |
-rw-r--r-- |
description: |
added phases |
3 ;; TODO 2024-05-09: add shell configurables to rules - maybe at sk-command 4 ;; level. :INPUT :WAIT :OUTPUT 7 (:use :cl :std :cli/clap 9 :dat/sxp #+tools :skel/tools/viz) 10 (:import-from :cli/shell :*shell-input*) 11 (:use :cli/tools/sbcl) 14 (in-package :bin/skel) 17 (defopt skc-help (print-help *cli*) *arg*) 18 (defopt skc-version (print-version *cli*)) 19 (defopt skc-level *log-level* 20 (setq *log-level* (if *arg* (if (stringp *arg*) 21 (sb-int:keywordicate (string-upcase *arg*)) 25 ;; TODO 2023-10-13: almost there 27 ;; (init-user-skelrc (when *arg* (parse-file-opt *arg*)))) 30 (let ((file (or (when *args* (pop *args*)) (sk-path *skel-project*)))) 31 (cli/ed:run-emacsclient (namestring file)))) 34 (let ((file (when *args* (pop *args*))) 35 (name (when (> *argc* 1) (pop *args*)))) 36 ;; TODO: test, may need to be 37 ;; sequential for side-effect 42 (std:println (format nil "file already exists: ~A" (or file *default-skelfile*))) 43 (let ((f2 (read-line))) 47 (init-skelfile file name)))) 52 (find-skelfile (pathname (car *args*)) :load t) 53 (or *skel-project* *skel-user-config* *skel-system-config*)))) 57 (sb-ext:enable-debugger) 61 (if *args* (pathname (car *args*)) 68 (let ((stuff (loop for a in *args* 69 collect (sk-slot-case a)))) 70 (sk-view (if (= 1 (length stuff)) (car stuff) stuff))) 71 (sk-view (if (boundp '*skel-project*) *skel-project* 72 (if (boundp '*skel-user-config*) *skel-user-config* 73 (if (boundp '*skel-system-config*) *skel-system-config* 74 (skel-simple-error "skel config files not installed"))))))) 77 (println (std:format-sxhash (obj/id:id (find-skelfile #P"." :load t))))) 79 (defun call-with-args (action args) 81 (sk-call *skel-project* action) 83 (sk-call *skel-project* (keywordicate action '- (string-upcase x)))) 87 (call-with-args :compile *args*)) 89 (call-with-args :build *args*)) 91 (call-with-args :dist *args*)) 93 (call-with-args :install *args*)) 95 (call-with-args :pack *args*)) 97 (call-with-args :unpack *args*)) 99 (call-with-args :bundle *args*)) 101 (call-with-args :unbundle *args*)) 103 (call-with-args :clean *args*)) 105 (call-with-args :test *args*)) 107 (call-with-args :bench *args*)) 109 (call-with-args :save *args*)) 111 (defun sk-slot-case (sel) 112 (std/string:string-case (sel :default (skel-simple-error "invalid slot")) 113 (":id" (std:format-sxhash (obj/id:id *skel-project*))) 114 (":name" (sk-name *skel-project*)) 115 (":author" (sk-author *skel-project*)) 116 (":version" (sk-version *skel-project*)) 117 (":description" (sk-description *skel-project*)) 118 (":tags" (sk-tags *skel-project*)) 119 (":license" (sk-license *skel-project*)) 120 (":vc" (sk-vc *skel-project*)) 121 (":components" (sk-components *skel-project*)) 122 (":scripts" (sk-scripts *skel-project*)) 123 (":rules" (sk-rules *skel-project*)) 124 (":phases" (hash-table-alist (sk-phases *skel-project*))) 125 (":env" (sk-env *skel-project*)) 126 (":bind" (sk-bind *skel-project*)) 127 (":include" (sk-include *skel-project*)) 128 (":stash" (sk-stash *skel-project*)) 129 (":store" (sk-store *skel-project*)) 130 (":config" *skel-user-config*) 131 (":sys" *skel-system-config*) 132 (":cache" (sk-cache *skel-user-config*)))) 136 (mapc (lambda (x) (when-let ((ret (sk-slot-case x))) (println ret))) *args*) 137 (describe (if (boundp '*skel-project*) *skel-project* 138 (if (boundp '*skel-user-config*) *skel-user-config* 139 (if (boundp '*skel-system-config*) *skel-system-config* 140 (skel-simple-error "skel config files not installed"))))))) 143 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 144 (:git (run-git-command "push" *args* t)) 145 (:hg (run-hg-command "push" *args* t)) 146 (t (skel-simple-error "unknown VC type")))) 149 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 150 (:git (run-git-command "pull" *args* t)) 151 (:hg (run-hg-command "pull" (append '("-u") *args*) t)) 152 (t (skel-simple-error "unknown VC type")))) 155 (with-open-stream (proc (process-output (run-hg-command "status" nil :stream))) 156 (loop for x = (read-line proc nil) 161 (with-open-stream (proc (run-git-command "status" nil :stream)) 162 (loop for x = (read-line proc nil) 167 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 173 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 174 (:git (run-git-command "clone" *args* t)) 175 (:hg (run-hg-command "clone" *args* t)) 176 (t (skel-simple-error "unknown VC type")))) 179 ;; (debug! *optc* *argc*) 180 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 181 (:git (run-git-command "commit" *args* t)) 182 (:hg (run-hg-command "commit" *args* t)) 183 (t (skel-simple-error "unknown VC type")))) 186 (let ((sk (find-skelfile #P"." :load t))) 187 (sb-ext:enable-debugger) 189 ;; (setq *no-exit* t) 191 (loop for a in *args* 193 (when-let ((rule (sk-find-rule a sk))) 195 (debug! (sk-make sk (aref (sk-rules sk) 0)))))) 199 (mapc (lambda (script) 203 (pathname-name script) 204 (find-skelfile #P"." :load t))))) *args*) 205 (required-argument 'name))) 209 (std/string:string-case ((car *args*) :default (skel-simple-error "invalid command")) 210 ("status" (skc-status nil nil))) 211 (skc-status nil *opts*))) 214 (sb-ext:enable-debugger) 215 (trace! "starting skel shell") 217 (cli/clap::with-cli-handlers 219 (in-package :sk-user) 220 (use-package :cl-user) 221 (use-package :sb-ext) 222 (use-package :std-user) 224 (println "Welcome to SKEL") 225 (sb-impl::toplevel-repl nil)))) 228 (trace! *args* *opts*)) 232 :version #.(format nil "0.1.1:~A" (read-line (sb-ext:process-output (vc:run-hg-command "id" '("-i") :stream)))) 233 :description "A hacker's project compiler." 235 :opts ((:name "help" :global t :description "print this message" 237 (:name "version" :global t :description "print version" 239 (:name "level" :global t :description "set log level (warn,info,debug,trace)" 241 (:name "config" :global t :description "set a custom skel user config" :kind file) 242 (:name "input" :global t :description "input source" :kind string) 243 (:name "output" :global t :description "output target" :kind string)) 245 :description "initialize a skelfile in the current directory" 246 :opts ((:name "name" :description "project name" :kind string)) 249 :description "make a new skel project" 250 :opts ((:name "name" :description "project name" :kind string)) 253 :description "describe a skelfile" 256 :description "show project slots" 257 :opts ((:name "file" :description "path to skelfile" :kind file) 258 (:name "user" :description "print user configuration") 259 (:name "system" :description "print system configuration")) 262 :description "version control" 264 :opts ((:name "root" :description "repository path" :kind directory))) 266 :description "print the project id" 269 :description "inspect the project skelfile" 270 :opts ((:name "file" :description "path to skelfile" :kind file)) 274 :description "view an object in a new GUI window" 277 :description "build project targets" 278 :opts ((:name "target" :description "target to build" :kind string)) 281 :description "run a script or command" 284 :description "compile source code" 287 :description "build programs and libraries" 290 :description "distribute build artifacts" 293 :description "install stuff" 296 :description "pack stuff" 299 :description "unpack stuff" 302 :description "bundle source code" 305 :description "unbundle source code" 308 :description "clean up the project" 311 :description "run tests" 314 :description "run benchmark" 317 :description "print the vc status" 320 :description "push the current project upstream" 323 :description "pull the current project from remote" 326 :description "clone a remote project" 329 :description "commit changes to the project vc" 332 :description "edit a project file in emacs." 335 :description "open the sk-shell interpreter" 339 (in-package :sk-user) 340 (let ((*log-level* :info)) 341 (in-readtable :shell) 342 (with-cli (opts cmds) *cli* 345 (when-let ((project (find-skelfile #P"."))) 346 (setq *skel-project* (load-skelfile project)))