changeset 337: |
4fc0ccc55bca |
parent: |
1e5e4bbcdf8b
|
child: |
1d281be30842 |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Mon, 13 May 2024 17:07:11 -0400 |
permissions: |
-rw-r--r-- |
description: |
edits to cli/clap arg processing |
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)) (find-skelfile #P".")))) 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 (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*) 73 (defun skc-show-case (sel) 74 (std/string:string-case (sel :default (skel-error)) 75 (":id" (std:format-sxhash (obj/id:id (find-skelfile #P"." :load t)))) 76 (":name" (sk-name (find-skelfile #P"." :load t))) 77 (":author" (sk-author (find-skelfile #P"." :load t))) 78 (":version" (sk-version (find-skelfile #P"." :load t))) 79 (":description" (sk-description (find-skelfile #P"." :load t))) 80 (":tags" (sk-tags (find-skelfile #P"." :load t))) 81 (":license" (sk-license (find-skelfile #P"." :load t))) 82 (":vc" (sk-vc (find-skelfile #P"." :load t))) 83 (":docs" (sk-docs (find-skelfile #P"." :load t))) 84 (":scripts" (sk-scripts (find-skelfile #P"." :load t))) 85 (":snippets" (sk-snippets (find-skelfile #P"." :load t))) 86 (":rules" (sk-rules (find-skelfile #P"." :load t))) 87 (":imports" (sk-imports (find-skelfile #P"." :load t))) 88 (":stash" (sk-stash (find-skelfile #P"." :load t))) 89 (":store" (sk-store (find-skelfile #P"." :load t))) 90 (":config" (if (probe-file *user-skelrc*) 91 (describe (load-user-skelrc) t) 92 (describe *skel-user-config* nil))) 93 (":cache" (sk-cache (find-skelfile #P"." :load t))))) 97 (mapc (lambda (x) (when-let ((ret (skc-show-case x))) (println ret))) $args) 98 (describe (find-skelfile #P"." :load t)))) 101 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 102 (:git (run-git-command "push" $args t)) 103 (:hg (run-hg-command "push" $args t)) 104 (t (skel-error "unknown VC type")))) 107 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 108 (:git (run-git-command "pull" $args t)) 109 (:hg (run-hg-command "pull" (push "-u" $args) t)) 110 (t (skel-error "unknown VC type")))) 113 (let ((proc (run-hg-command "status" nil :stream))) 114 (copy-stream (process-output proc) *standard-output*) 118 (let ((proc (run-git-command "status" nil :stream))) 119 (copy-stream (process-output proc) *standard-output*) 123 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 129 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 130 (:git (run-git-command "clone" $args t)) 131 (:hg (run-hg-command "clone" $args t)) 132 (t (skel-error "unknown VC type")))) 136 (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) 137 (:git (run-git-command "commit" $args t)) 138 (:hg (run-hg-command "commit" $args t)) 139 (t (skel-error "unknown VC type")))) 142 (let ((sk (find-skelfile #P"." :load t))) 143 (sb-ext:enable-debugger) 147 (when-let ((rule (sk-find-rule a sk))) 149 (debug! (sk-make sk (aref (sk-rules sk) 0)))))) 153 (mapc (lambda (script) 157 (pathname-name script) 158 (find-skelfile #P"." :load t))))) $args) 159 (required-argument :script))) 162 (sb-ext:enable-debugger) 164 (cli/clap::with-cli-handlers 166 (use-package :cl-user) 167 (use-package :sb-ext) 168 (use-package :std-user) 170 (sb-impl::toplevel-repl nil)))) 175 :description "A hacker's project compiler and build tool." 178 (:name "help" :global t :description "print this message" 180 (:name "version" :global t :description "print version" 182 (:name "level" :global t :description "set log level (warn,info,debug,trace)" 184 (:name "config" :global t :description "set a custom skel user config" :kind file 186 (:name "input" :global t :description "input source" :kind string) 187 (:name "output" :global t :description "output target" :kind string)) 190 :description "initialize a skelfile in the current directory" 191 :opts (make-opts (:name "name" :description "project name" :kind string)) 194 :description "describe a skelfile" 197 :description "show project slots" 199 (:name "file" :description "path to skelfile" :kind file) 200 (:name "user" :description "print user configuration") 201 (:name "system" :description "print system configuration")) 204 :description "print the project id" 207 :description "print the current vc revision id" 210 :description "inspect the project skelfile" 211 :opts (make-opts (:name "file" :description "path to skelfile" :kind file)) 214 :description "build project targets" 215 :opts (make-opts (:name "target" :description "target to build" :kind string)) 218 :description "run a script or command" 221 :description "print the vc status" 224 :description "push the current project upstream" 227 :description "pull the current project from remote" 230 :description "clone a remote project" 233 :description "commit changes to the project vc" 234 :opts (make-opts (:name "message" :description "commit message" :kind string :thunk identity)) 237 :description "edit a project file in emacs." 240 :description "open the sk-shell interpreter" 244 (:use :cl :std :skel)) 247 (in-package :sk-user) 248 (let ((*log-level* :info)) 249 (in-readtable :shell) 250 (with-cli (opts cmds) $cli 252 ;; TODO 2024-01-01: need to parse out CMD opts from args slot - they still there 253 (do-opt (find-opt $cli "level"))