changeset 363: |
a5a2d756ee2f |
parent: |
aac665e2f5bf
|
child: |
45889d307d7f |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Thu, 23 May 2024 19:07:51 -0400 |
permissions: |
-rw-r--r-- |
description: |
fix define-cli |
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 sk-slot-case (sel) 75 (std/string:string-case (sel :default (skel-error "invalid slot")) 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 (":env" (sk-env *skel-project*)) 89 (":vars" (sk-vars *skel-project*)) 90 (":imports" (sk-imports *skel-project*)) 91 (":stash" (sk-stash *skel-project*)) 92 (":store" (sk-store *skel-project*)) 93 (":config" (describe *skel-user-config*)) 94 (":sys" (describe *skel-system-config*)) 95 (":cache" (sk-cache *skel-user-config*)))) 99 (mapc (lambda (x) (when-let ((ret (sk-slot-case x))) (println ret))) $args) 100 (describe (if (boundp '*skel-project*) *skel-project* 101 (if (boundp '*skel-user-config*) *skel-user-config* 102 (if (boundp '*skel-system-config*) *skel-system-config* 103 (skel-error "skel config files not installed"))))))) 106 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 107 (:git (run-git-command "push" $args t)) 108 (:hg (run-hg-command "push" $args t)) 109 (t (skel-error "unknown VC type")))) 112 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 113 (:git (run-git-command "pull" $args t)) 114 (:hg (run-hg-command "pull" (push "-u" $args) t)) 115 (t (skel-error "unknown VC type")))) 118 (let ((proc (run-hg-command "status" nil :stream))) 119 (copy-stream (process-output proc) *standard-output*) 123 (let ((proc (run-git-command "status" nil :stream))) 124 (copy-stream (process-output proc) *standard-output*) 128 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 134 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 135 (:git (run-git-command "clone" $args t)) 136 (:hg (run-hg-command "clone" $args t)) 137 (t (skel-error "unknown VC type")))) 140 ;; (debug! $optc $argc) 141 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 142 (:git (run-git-command "commit" $args t)) 143 (:hg (run-hg-command "commit" $args t)) 144 (t (skel-error "unknown VC type")))) 147 (let ((sk (find-skelfile #P"." :load t))) 148 (sb-ext:enable-debugger) 153 (when-let ((rule (sk-find-rule a sk))) 155 (debug! (sk-make sk (aref (sk-rules sk) 0)))))) 159 (mapc (lambda (script) 163 (pathname-name script) 164 (find-skelfile #P"." :load t))))) $args) 165 (required-argument :script))) 168 (sb-ext:enable-debugger) 169 (trace! "starting skel shell") 171 (cli/clap::with-cli-handlers 173 (in-package :sk-user) 174 (use-package :cl-user) 175 (use-package :sb-ext) 176 (use-package :std-user) 178 (println "Welcome to SKEL") 179 (sb-impl::toplevel-repl nil)))) 184 :description "A hacker's project compiler." 187 (:name "help" :global t :description "print this message" 189 (:name "version" :global t :description "print version" 191 (:name "level" :global t :description "set log level (warn,info,debug,trace)" 193 (:name "config" :global t :description "set a custom skel user config" :kind file) 194 (:name "input" :global t :description "input source" :kind string) 195 (:name "output" :global t :description "output target" :kind string)) 198 :description "initialize a skelfile in the current directory" 199 :opts (make-opts (:name "name" :description "project name" :kind string)) 202 :description "describe a skelfile" 205 :description "show project slots" 207 (:name "file" :description "path to skelfile" :kind file) 208 (:name "user" :description "print user configuration") 209 (:name "system" :description "print system configuration")) 212 :description "print the project id" 215 :description "print the current vc revision id" 218 :description "inspect the project skelfile" 219 :opts (make-opts (:name "file" :description "path to skelfile" :kind file)) 222 :description "build project targets" 223 :opts (make-opts (:name "target" :description "target to build" :kind string)) 226 :description "run a script or command" 229 :description "print the vc status" 232 :description "push the current project upstream" 235 :description "pull the current project from remote" 238 :description "clone a remote project" 241 :description "commit changes to the project vc" 244 :description "edit a project file in emacs." 247 :description "open the sk-shell interpreter" 251 (:use :cl :std :skel)) 254 (in-package :sk-user) 255 (let ((*log-level* :info)) 256 (in-readtable :shell) 257 (with-cli (opts cmds) $cli 259 (when-let ((project (find-skelfile #P"."))) 260 (setq *skel-project* (load-skelfile project)))