changelog shortlog graph tags branches files raw help

Mercurial > core / changeset: special vars for skel bin

changeset 340: 5ac5e6516f6f
parent 339: 8f1c1d79a96c
child 341: ce1c1743c85f
author: Richard Westhaver <ellis@rwest.io>
date: Mon, 13 May 2024 18:37:13 -0400
files: lisp/bin/skel.lisp lisp/lib/skel/core/util.lisp
description: special vars for skel bin
     1.1--- a/lisp/bin/skel.lisp	Mon May 13 18:07:07 2024 -0400
     1.2+++ b/lisp/bin/skel.lisp	Mon May 13 18:37:13 2024 -0400
     1.3@@ -24,7 +24,7 @@
     1.4 ;;   (init-user-skelrc (when $val (parse-file-opt $val))))
     1.5 
     1.6 (defcmd skc-edit
     1.7-  (let ((file (or (when $args (pop $args)) (find-skelfile #P"."))))
     1.8+  (let ((file (or (when $args (pop $args)) (sk-path *skel-project*))))
     1.9     (cli/ed:run-emacsclient (namestring file))))
    1.10 
    1.11 (defcmd skc-init
    1.12@@ -60,40 +60,45 @@
    1.13   (println (std:format-sxhash (obj/id:id (find-skelfile #P"." :load t)))))
    1.14 
    1.15 (defcmd skc-rev
    1.16-  (case (sk-vc (find-skelfile #P"." :load t))
    1.17+  (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t)))
    1.18     (:hg (progn
    1.19            (let ((proc (run-hg-command "id" (list "-i") :stream)))
    1.20              (copy-stream (process-output proc) *standard-output*)
    1.21              (finish-output))))
    1.22-    (t (progn
    1.23-         (let ((proc (run-git-command "rev-parse" (list "HEAD") :stream)))
    1.24-           (copy-stream (process-output proc) *standard-output*)
    1.25-           (finish-output))))))
    1.26+    (:git (progn
    1.27+            (let ((proc (run-git-command "rev-parse" (list "HEAD") :stream)))
    1.28+              (copy-stream (process-output proc) *standard-output*)
    1.29+              (finish-output))))
    1.30+    (t (skel-error "unknown VC type"))))
    1.31 
    1.32 (defun skc-show-case (sel)
    1.33   (std/string:string-case (sel :default (skel-error))
    1.34-    (":id" (std:format-sxhash (obj/id:id (find-skelfile #P"." :load t))))
    1.35-    (":name" (sk-name (find-skelfile #P"." :load t)))
    1.36-    (":author" (sk-author (find-skelfile #P"." :load t)))
    1.37-    (":version" (sk-version (find-skelfile #P"." :load t)))
    1.38-    (":description" (sk-description (find-skelfile #P"." :load t)))
    1.39-    (":tags" (sk-tags (find-skelfile #P"." :load t)))
    1.40-    (":license" (sk-license (find-skelfile #P"." :load t)))
    1.41-    (":vc" (sk-vc (find-skelfile #P"." :load t)))
    1.42-    (":docs" (sk-docs (find-skelfile #P"." :load t)))
    1.43-    (":scripts" (sk-scripts (find-skelfile #P"." :load t)))
    1.44-    (":snippets" (sk-snippets (find-skelfile #P"." :load t)))
    1.45-    (":rules" (sk-rules (find-skelfile #P"." :load t)))
    1.46-    (":imports" (sk-imports (find-skelfile #P"." :load t)))
    1.47-    (":stash" (sk-stash (find-skelfile #P"." :load t)))
    1.48-    (":store" (sk-store (find-skelfile #P"." :load t)))
    1.49-    (":config" (describe *skel-user-config* nil))
    1.50+    (":id" (std:format-sxhash (obj/id:id *skel-project*)))
    1.51+    (":name" (sk-name *skel-project*))
    1.52+    (":author" (sk-author *skel-project*))
    1.53+    (":version" (sk-version *skel-project*))
    1.54+    (":description" (sk-description *skel-project*))
    1.55+    (":tags" (sk-tags *skel-project*))
    1.56+    (":license" (sk-license *skel-project*))
    1.57+    (":vc" (sk-vc *skel-project*))
    1.58+    (":docs" (sk-docs *skel-project*))
    1.59+    (":scripts" (sk-scripts *skel-project*))
    1.60+    (":snippets" (sk-snippets *skel-project*))
    1.61+    (":rules" (sk-rules *skel-project*))
    1.62+    (":imports" (sk-imports *skel-project*))
    1.63+    (":stash" (sk-stash *skel-project*))
    1.64+    (":store" (sk-store *skel-project*))
    1.65+    (":config" (describe *skel-user-config*))
    1.66+    (":sys" (describe *skel-system-config*))
    1.67     (":cache" (sk-cache *skel-user-config*))))
    1.68 
    1.69 (defcmd skc-show
    1.70   (if $args 
    1.71       (mapc (lambda (x) (when-let ((ret (skc-show-case x))) (println ret))) $args)
    1.72-      (describe (find-skelfile #P"." :load t))))
    1.73+      (describe (if (boundp '*skel-project*) *skel-project*
    1.74+                    (if (boundp '*skel-user-config*) *skel-user-config*
    1.75+                        (if (boundp '*skel-system-config*) *skel-system-config*
    1.76+                            (skel-error "skel config files not installed")))))))
    1.77 
    1.78 (defcmd skc-push
    1.79   (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t)))
    1.80@@ -248,5 +253,7 @@
    1.81     (in-readtable :shell)
    1.82     (with-cli (opts cmds) $cli
    1.83       (load-skelrc)
    1.84+      (when-let ((project (find-skelfile #P".")))
    1.85+        (setq *skel-project* (load-skelfile project)))
    1.86       (do-cmd $cli)
    1.87       (debug-opts $cli))))
     2.1--- a/lisp/lib/skel/core/util.lisp	Mon May 13 18:07:07 2024 -0400
     2.2+++ b/lisp/lib/skel/core/util.lisp	Mon May 13 18:37:13 2024 -0400
     2.3@@ -77,7 +77,7 @@
     2.4       (when cfg (setf sk (sk-install-user-config sk cfg)))
     2.5       (sk-write-file sk :path path :fmt fmt))))
     2.6 
     2.7-(defun find-skelfile (start &key (load nil) (filename *default-skelfile*) (walk t))
     2.8+(defun find-skelfile (start &key (load nil) (filename *default-skelfile*) (walk t) error)
     2.9   "Walk up the current directory returning the path to a 'skelfile', else
    2.10 return nil. When LOAD is non-nil, load the skelfile if found."
    2.11   ;; Check the current path, if no skelfile found, walk up a level and
    2.12@@ -88,24 +88,12 @@
    2.13 	    (if load
    2.14 		(load-skelfile (merge-pathnames filename root))
    2.15 		(merge-pathnames filename root))
    2.16-	    (error "failed to find root skelfile")))
    2.17+	    (when error (error "failed to find root skelfile"))))
    2.18       (if-let ((sk (probe-file (merge-pathnames filename start))))
    2.19 	(if load 
    2.20 	    (load-skelfile sk)
    2.21 	    sk)
    2.22-	(error "failed to find root skelfile"))))
    2.23-
    2.24-(defun describe-skeleton (skel &optional (stream t))
    2.25-  "Describe the object SKEL which should inherit from the `skel' superclass."
    2.26-  (print-object skel stream)
    2.27-  (terpri stream))
    2.28-
    2.29-(defun describe-project (&optional path (stream t))
    2.30-  "Describe the project responsible for the pathname PATH. Defaults to
    2.31-`sb-posix:getcwd'."
    2.32-  (let* ((cd (or path (sb-posix:getcwd))))
    2.33-    (print cd stream)
    2.34-    (terpri stream)))
    2.35+	(when error (error "failed to find root skelfile")))))
    2.36 
    2.37 (defun edit-skelrc ()
    2.38   "Open the current user configuration using ED."