Skip to content

Commit

Permalink
feat: Add info command
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Oct 24, 2024
1 parent 5b762ac commit 847b860
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
Expand Down Expand Up @@ -63,4 +67,8 @@ See [`LICENSE`](./LICENSE) for details.

<!-- Links -->

[ASDF]: https://asdf.common-lisp.dev/
[Quicklisp]: https://www.quicklisp.org/beta/

[Roswell]: https://roswell.github.io/
[Qlot]: https://github.com/fukamachi/qlot
32 changes: 32 additions & 0 deletions cmds/core/info.lisp
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions cmds/qob.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions lisp/_prepare.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lisp/core/dists.lisp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;;; lisp/core/dists.lisp --- Build executable
;;;; lisp/core/dists.lisp --- List out all dists

;;; Commentary
;;
Expand Down
53 changes: 53 additions & 0 deletions lisp/core/info.lisp
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions qob-cli.asd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down

0 comments on commit 847b860

Please sign in to comment.