diff --git a/README.md b/README.md index 365bbb6..5dbdc1b 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ [![CI](https://github.com/cl-qob/cli/actions/workflows/test.yml/badge.svg)](https://github.com/cl-qob/cli/actions/workflows/test.yml) +## 🏆 Features + +WIP + ## 🔧 Usage ``` @@ -63,4 +67,8 @@ See [`LICENSE`](./LICENSE) for details. +[ASDF]: https://asdf.common-lisp.dev/ [Quicklisp]: https://www.quicklisp.org/beta/ + +[Roswell]: https://roswell.github.io/ +[Qlot]: https://github.com/fukamachi/qlot diff --git a/cmds/core/info.lisp b/cmds/core/info.lisp new file mode 100644 index 0000000..a3ca8ad --- /dev/null +++ b/cmds/core/info.lisp @@ -0,0 +1,32 @@ +;;;; cmds/core/info.lisp --- Build executable + +;;; Commentary +;; +;; The `info' command definition. +;; + +;;; Code + +(defpackage qob-cli/info + (:use cl) + (:export command)) + +(in-package :qob-cli/info) + +(defun options () + "Options for `info' command." + (list )) + +(defun handler (cmd) + "Handler for `info' command." + (qob-cli:call-script "core/info" cmd)) + +(defun command () + "The `info' command." + (clingon:make-command + :name "info" + :description "Display information about the current system(s)" + :options (options) + :handler #'handler)) + +;;; End of cmds/core/info.lisp diff --git a/cmds/qob.lisp b/cmds/qob.lisp index 216d197..1226fa8 100644 --- a/cmds/qob.lisp +++ b/cmds/qob.lisp @@ -57,6 +57,7 @@ :handler #'handler :sub-commands `(,(qob-cli/build:command) ,(qob-cli/dists:command) + ,(qob-cli/info:command) ,(qob-cli/install:command) ,(qob-cli/install-deps:command) ,(qob-cli/uninstall:command) diff --git a/lisp/_prepare.lisp b/lisp/_prepare.lisp index 410fe3a..3b98399 100644 --- a/lisp/_prepare.lisp +++ b/lisp/_prepare.lisp @@ -295,6 +295,15 @@ Execute forms BODY limit by the verbosity level (SYMBOL)." "Progress BODY wrapper with prefix (MSG-START) and suffix (MSG-END) messages." `(progn (qob-write ,msg-start) ,body (qob-msg ,msg-end))) +;; +;;; ASDF + +(defun qob-system-version (name) + "Get the system version." + (let ((system (asdf:find-system name nil))) + (when (and system (slot-boundp system 'asdf:version)) + (asdf:component-version system)))) + ;; ;;; Package diff --git a/lisp/core/dists.lisp b/lisp/core/dists.lisp index 5fcc6b6..d641cde 100644 --- a/lisp/core/dists.lisp +++ b/lisp/core/dists.lisp @@ -1,4 +1,4 @@ -;;;; lisp/core/dists.lisp --- Build executable +;;;; lisp/core/dists.lisp --- List out all dists ;;; Commentary ;; diff --git a/lisp/core/info.lisp b/lisp/core/info.lisp new file mode 100644 index 0000000..dc5ce68 --- /dev/null +++ b/lisp/core/info.lisp @@ -0,0 +1,53 @@ +;;;; lisp/core/info.lisp --- Print systems info + +;;; Commentary +;; +;; Command use to print systems info, +;; +;; $ qob info +;; + +;;; Code + +(qob-init-asds) + +(defun qob-info--print-system (name system) + "Print the SYSTEM info." + (let ((author (asdf:system-author system)) + (maintainer (asdf:system-maintainer system)) + (version (asdf:component-version system)) + (description (asdf:system-description system)) + (homepage (asdf:system-homepage system)) + (license (asdf:system-license system)) + (depends-on (asdf:system-depends-on system))) + (qob-println "~A (~A) | deps: ~A" + (qob-ansi-green name) + (qob-ansi-yellow version) + (qob-ansi-cyan (length depends-on))) + (when description + (qob-println description)) + (when homepage + (qob-println (qob-ansi-cyan homepage))) + (when author + (qob-println "") + (qob-println "Author: ~A" (qob-ansi-white author))) + (when maintainer + (qob-println "Maintainer: ~A" (qob-ansi-white maintainer))) + (when license + (qob-println "License: ~A" (qob-ansi-white license))) + (when depends-on + (qob-println "") + (qob-println "dependencies:") + (dolist (dep depends-on) + ;; TODO: Print system version? + (qob-println " ~A" dep))))) + +(let ((names qob-args)) + (cond ((zerop (length names)) + (qob-help "core/info")) + (t + (dolist (name names) + (let ((system (asdf:find-system name))) + (qob-info--print-system name system)))))) + +;;; End of lisp/core/info.lisp diff --git a/qob-cli.asd b/qob-cli.asd index 22d9d55..acc0d53 100644 --- a/qob-cli.asd +++ b/qob-cli.asd @@ -3,6 +3,7 @@ :author "Jen-Chieh Shen" :license "MIT" :description "CLI for building, running, testing, and managing your Common Lisp dependencies" + :homepage "https://github.com/cl-qob/cli" :depends-on ("cl-autorepo" "clingon") :serial t :components (;; Utils @@ -12,6 +13,7 @@ ;; Commands (:file "cmds/core/build") (:file "cmds/core/dists") + (:file "cmds/core/info") (:file "cmds/core/install") (:file "cmds/core/install-deps") (:file "cmds/core/uninstall")