~skin/zippm

6c61fd74559a0f6db2b39b2af29702a1b94117f1 — Daniel Jay Haskin 7 months ago
Start re-writing and consolidating
11 files changed, 264 insertions(+), 0 deletions(-)

A .gitattributes
A .gitignore
A README.markdown
A README.org
A qlfile
A qlfile.lock
A src/main.lisp
A src/resolve.lisp
A tests/main.lisp
A zippm.asd
A zippm.ros
A  => .gitattributes +23 -0
@@ 1,23 @@
# Linux
*.sh text eol=lf
*.screen text eol=lf

## Lighttpd stuff
*.conf text eol=lf
*.pem text eol=lf
*.crt text eol=lf

# Windows
*.ps1 text eol=crlf

# Both OS's
*.lisp text
*.asd text
*.md text
*.lock text
qlfile text
.gitignore text

# Images
*.png binary
*.jpg binary

A  => .gitignore +21 -0
@@ 1,21 @@
*.abcl
*.fasl
*.dx32fsl
*.dx64fsl
*.lx32fsl
*.lx64fsl
*.x86f
*~
.#*
.*.sw[a-z]
/.slime_paste
/.vagrant/
/scratch.lisp
/*.log
TODO
/.repl/ros_history

/.qlot/
/.bundle-libs/
/zippm.exe
/zippm

A  => README.markdown +5 -0
@@ 1,5 @@
# Zippm

## Usage

## Installation

A  => README.org +5 -0
@@ 1,5 @@
* Zippm 

** Usage

** Installation

A  => qlfile +5 -0
@@ 1,5 @@
ql trivial-package-local-nicknames
ql trivial-features
ql trivial-indent
ql alexandria
git cl-i git@git.sr.ht:~skin/cl-i :branch main

A  => qlfile.lock +24 -0
@@ 1,24 @@
("quicklisp" .
 (:class qlot/source/dist:source-dist
  :initargs (:distribution "https://beta.quicklisp.org/dist/quicklisp.txt" :%version :latest)
  :version "2023-10-21"))
("trivial-package-local-nicknames" .
 (:class qlot/source/ql:source-ql
  :initargs (:%version :latest)
  :version "ql-2023-10-21"))
("trivial-features" .
 (:class qlot/source/ql:source-ql
  :initargs (:%version :latest)
  :version "ql-2023-10-21"))
("trivial-indent" .
 (:class qlot/source/ql:source-ql
  :initargs (:%version :latest)
  :version "ql-2023-10-21"))
("alexandria" .
 (:class qlot/source/ql:source-ql
  :initargs (:%version :latest)
  :version "ql-2023-10-21"))
("cl-i" .
 (:class qlot/source/git:source-git
  :initargs (:remote-url "git@git.sr.ht:~skin/cl-i" :branch "main")
  :version "git-2c5681b4db0a84e707ee20b8a0feb83424783b9e"))

A  => src/main.lisp +51 -0
@@ 1,51 @@
(defpackage #:skin.djha.zippm
  (:use :cl)
  (:import-from #:uiop)
  (:import-from #:alexandria)
  (:import-from #:cl-i)
  (:export
    entrypoint))

(in-package #:skin.djha.zippm)

(defun stub (options name)
  (let ((strm (gethash :strm options)))
    (format strm "~A~%" name)
    (loop for k being the hash-keys of options
          using (hash-value v)
          do (format strm "~39@A: ~A~%" k v)
          finally (return (alexandria:alist-hash-table
                            `((:status . :successful)
                              (:options . ,options))
                            :test #'equal)))))

(defun athing (options)
  (declare (type hash-table options))
  (stub options "athing"))

(defun main (argv &key (strm t))
  "
  The functional entrypoint of the zippm command.
  "
  (declare (type list argv))
    (cl-i:execute-program
      "zippm"
      (cl-i:system-environment-variables)
      `(
        (("athing") . ,#'athing)
        )
      :helps
      `((("athing") . "A stub function"))
      :cli-arguments argv
      :setup (lambda (opts)
               (setf (gethash :strm opts) strm)
               opts)
      :teardown (lambda (result)
                  (format strm "~A~%"
                          (cl-i:generate-string result :pretty 4)
                          )
                  result)))

(defun entrypoint (argv)
  (uiop:quit
    (main argv :strm *standard-output*)))

A  => src/resolve.lisp +43 -0
@@ 1,43 @@
(defpackage #:skin.djha.zippm/resolve
  (:use :cl)
  (:import-from #:uiop)
  (:import-from #:alexandria)
  )

(in-package #:skin.djha.zippm/resolve)

(defparameter relation-strings
  (alexandria:alist-hash-table
    '((:greater-than . ">")
      (:greater-equal . ">=")
      (:equal-to . "==")
      (:not-equal . "!=")
      (:less-equal . "<=")
      (:less-than . "<")
      (:matches . "<>")
      (:in-range . "=>")
      (:pess-greater . "><"))))

(defclass version-predicate ()
  ((relation :initarg :relation :reader relation)
   (version :initarg :version :reader version))
  (:documentation "A class to represent a version predicate."))

(defmethod print-object ((obj version-predicate) strm)
  (format strm "~A~A"
          (gethash (relation obj) relation-strings)
          (version obj)))

(defclass requirement ()
  ((status :initarg :status :reader status)
   (name :initarg :name :reader name)
   (spec :initarg :spec :reader spec))
  (:documentation "A package requirement."))

(defmethod print-object ((obj requirement) strm)
    (format strm "~:[!~;~]~A~{~{~A~^,~}~^;~}"
            (eql :present (status obj))
            (name obj)
            (spec obj)))



A  => tests/main.lisp +38 -0
@@ 1,38 @@
(defpackage #:zippm/tests/resolve
  (:use #:cl
        #:skin.djha.zippm/resolve
        #:rove))
(in-package #:zippm/tests/resolve)

;; NOTE: To run this test file, execute `(asdf:test-system :zippm)' in your Lisp.
+(or)
(rove:run-test *)

(deftest basic-structures
  (testing
    "Make a version predicate"
    (let ((p (make-instance 'skin.djha.zippm/resolve::version-predicate
                            :relation :greater-equal
                            :version "1.0"))
          (q (make-instance 'skin.djha.zippm/resolve::version-predicate
                            :relation :less-than
                            :version "2.0"))
          (s (make-instance 'skin.djha.zippm/resolve::version-predicate
                            :relation :equal-to
                            :version "2.3")))

        (ok (string=
              (format nil "~A" p)
              ">=1.0"))
      (let ((present-r (make-instance 'skin.djha.zippm/resolve::requirement
                              :status :present
                              :name "foo"
                              :spec
                                `(
                                  (,p ,q)
                                  (,s)))))
        (ok (string=
              (format nil "~A" present-r)
              "foo>=1.0,<2.0;==2.3")

              "foo>=1.0,<2.0;==2.3")))))

A  => zippm.asd +25 -0
@@ 1,25 @@
(defsystem "zippm"
  :version "0.1.0"
  :author "Daniel Jay Haskin"
  :license "MIT"
  :depends-on (
               "cl-i"
               "alexandria"
  )
  :components ((:module "src"
                :components
                ((:file "main"))))
  :description ""
  :in-order-to ((test-op (test-op "zippm/tests"))))

(defsystem "zippm/tests"
  :author "Daniel Jay Haskin"
  :license "MIT"
  :version "0.1.0"
  :depends-on ("zippm"
               "rove")
  :components ((:module "tests"
                :components
                ((:file "main"))))
  :description "Test system for zippm"
  :perform (test-op (op c) (symbol-call :rove :run c)))

A  => zippm.ros +24 -0
@@ 1,24 @@
#!/bin/sh
#|-*- mode:lisp -*-|#
#|
exec ros -Q -- $0 "$@"
|#
(progn ;;init forms
  (ros:ensure-asdf)
  #+quicklisp(ql:quickload '() :silent t)
  )

(asdf:load-system "zippm")

(defpackage :ros.script.zippm.3916575100
  (:use :cl)
  (:import-from #:skin.djha.zippm))
(in-package :ros.script.zippm.3916575100)


(defun main (&rest argv)
  (declare (ignorable argv))
  (skin.djha.zippm:entrypoint argv))


;;; vim: set ft=lisp lisp: