changeset 340: |
5ac5e6516f6f |
parent: |
8f1c1d79a96c
|
child: |
ce1c1743c85f |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Mon, 13 May 2024 18:37:13 -0400 |
permissions: |
-rw-r--r-- |
description: |
special vars for skel bin |
3 ;; TODO 2024-05-09: add shell configurables to rules - maybe at sk-command 4 ;; level. :INPUT :WAIT :OUTPUT 6 (uiop:define-package :bin/skel 7 (:use :cl :std :cli/clap :vc :sb-ext) 8 (:import-from :cli/shell :*shell-input*) 9 (:use-reexport :skel :log) 12 (in-package :bin/skel) 15 (defopt skc-help (print-help $cli) $val) 16 (defopt skc-version (print-version $cli)) 17 (defopt skc-level *log-level* (setq *log-level* (if $val (if (stringp $val) 18 (sb-int:keywordicate (string-upcase $val)) 22 ;; TODO 2023-10-13: almost there 24 ;; (init-user-skelrc (when $val (parse-file-opt $val)))) 27 (let ((file (or (when $args (pop $args)) (sk-path *skel-project*)))) 28 (cli/ed:run-emacsclient (namestring file)))) 31 (let ((file (when $args (pop $args))) 32 (name (if (> $argc 1) (pop $args)))) 36 (uiop:println (format nil "file already exists: ~A" (or file *default-skelfile*))) 37 (let ((f2 (read-line))) 41 (init-skelfile file name)))) 46 (if $args (pathname (car $args)) 51 (sb-ext:enable-debugger) 55 (if $args (pathname (car $args)) 60 (println (std:format-sxhash (obj/id:id (find-skelfile #P"." :load t))))) 63 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 65 (let ((proc (run-hg-command "id" (list "-i") :stream))) 66 (copy-stream (process-output proc) *standard-output*) 69 (let ((proc (run-git-command "rev-parse" (list "HEAD") :stream))) 70 (copy-stream (process-output proc) *standard-output*) 72 (t (skel-error "unknown VC type")))) 74 (defun skc-show-case (sel) 75 (std/string:string-case (sel :default (skel-error)) 76 (":id" (std:format-sxhash (obj/id:id *skel-project*))) 77 (":name" (sk-name *skel-project*)) 78 (":author" (sk-author *skel-project*)) 79 (":version" (sk-version *skel-project*)) 80 (":description" (sk-description *skel-project*)) 81 (":tags" (sk-tags *skel-project*)) 82 (":license" (sk-license *skel-project*)) 83 (":vc" (sk-vc *skel-project*)) 84 (":docs" (sk-docs *skel-project*)) 85 (":scripts" (sk-scripts *skel-project*)) 86 (":snippets" (sk-snippets *skel-project*)) 87 (":rules" (sk-rules *skel-project*)) 88 (":imports" (sk-imports *skel-project*)) 89 (":stash" (sk-stash *skel-project*)) 90 (":store" (sk-store *skel-project*)) 91 (":config" (describe *skel-user-config*)) 92 (":sys" (describe *skel-system-config*)) 93 (":cache" (sk-cache *skel-user-config*)))) 97 (mapc (lambda (x) (when-let ((ret (skc-show-case x))) (println ret))) $args) 98 (describe (if (boundp '*skel-project*) *skel-project* 99 (if (boundp '*skel-user-config*) *skel-user-config* 100 (if (boundp '*skel-system-config*) *skel-system-config* 101 (skel-error "skel config files not installed"))))))) 104 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 105 (:git (run-git-command "push" $args t)) 106 (:hg (run-hg-command "push" $args t)) 107 (t (skel-error "unknown VC type")))) 110 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 111 (:git (run-git-command "pull" $args t)) 112 (:hg (run-hg-command "pull" (push "-u" $args) t)) 113 (t (skel-error "unknown VC type")))) 116 (let ((proc (run-hg-command "status" nil :stream))) 117 (copy-stream (process-output proc) *standard-output*) 121 (let ((proc (run-git-command "status" nil :stream))) 122 (copy-stream (process-output proc) *standard-output*) 126 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 132 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 133 (:git (run-git-command "clone" $args t)) 134 (:hg (run-hg-command "clone" $args t)) 135 (t (skel-error "unknown VC type")))) 138 ;; (debug! $optc $argc) 139 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 140 (:git (run-git-command "commit" $args t)) 141 (:hg (run-hg-command "commit" $args t)) 142 (t (skel-error "unknown VC type")))) 145 (let ((sk (find-skelfile #P"." :load t))) 146 (sb-ext:enable-debugger) 150 (when-let ((rule (sk-find-rule a sk))) 152 (debug! (sk-make sk (aref (sk-rules sk) 0)))))) 156 (mapc (lambda (script) 160 (pathname-name script) 161 (find-skelfile #P"." :load t))))) $args) 162 (required-argument :script))) 165 (sb-ext:enable-debugger) 166 (trace! "starting skel shell") 168 (cli/clap::with-cli-handlers 170 (in-package :sk-user) 171 (use-package :cl-user) 172 (use-package :sb-ext) 173 (use-package :std-user) 175 (println "Welcome to SKEL") 176 (sb-impl::toplevel-repl nil)))) 181 :description "A hacker's project compiler and build tool." 184 (:name "help" :global t :description "print this message" 186 (:name "version" :global t :description "print version" 188 (:name "level" :global t :description "set log level (warn,info,debug,trace)" 190 (:name "config" :global t :description "set a custom skel user config" :kind file) 191 (:name "input" :global t :description "input source" :kind string) 192 (:name "output" :global t :description "output target" :kind string)) 195 :description "initialize a skelfile in the current directory" 196 :opts (make-opts (:name "name" :description "project name" :kind string)) 199 :description "describe a skelfile" 202 :description "show project slots" 204 (:name "file" :description "path to skelfile" :kind file) 205 (:name "user" :description "print user configuration") 206 (:name "system" :description "print system configuration")) 209 :description "print the project id" 212 :description "print the current vc revision id" 215 :description "inspect the project skelfile" 216 :opts (make-opts (:name "file" :description "path to skelfile" :kind file)) 219 :description "build project targets" 220 :opts (make-opts (:name "target" :description "target to build" :kind string)) 223 :description "run a script or command" 226 :description "print the vc status" 229 :description "push the current project upstream" 232 :description "pull the current project from remote" 235 :description "clone a remote project" 238 :description "commit changes to the project vc" 241 :description "edit a project file in emacs." 244 :description "open the sk-shell interpreter" 248 (:use :cl :std :skel)) 251 (in-package :sk-user) 252 (let ((*log-level* :info)) 253 (in-readtable :shell) 254 (with-cli (opts cmds) $cli 256 (when-let ((project (find-skelfile #P"."))) 257 (setq *skel-project* (load-skelfile project)))