Skip to content

Commit

Permalink
Add a command line utility to build static site from the cli.
Browse files Browse the repository at this point in the history
  • Loading branch information
svetlyak40wt committed Apr 29, 2024
1 parent 551e476 commit 7574ac9
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.*.~undo-tree~
*.fasl
/example/stage/
/stage/
15 changes: 15 additions & 0 deletions roswell/staticl.ros
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
#|-*- mode:lisp -*-|#
#|
exec ros -Q -- $0 "$@"
|#
(progn
(ros:ensure-asdf)
#+quicklisp
(ql:quickload '("staticl"
"staticl/main")
:silent t))

(in-package #:staticl/main)

;;; vim: set ft=lisp lisp:
46 changes: 46 additions & 0 deletions src/main.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
(uiop:define-package #:staticl/main
(:use #:cl)
(:import-from #:staticl/core
#:stage)
(:import-from #:defmain
#:subcommand
#:defcommand
#:defmain))
(in-package #:staticl/main)


(defvar *verbose* nil)


(defmain (main :program-name "staticl") ((verbose "Output more information"
:flag t)
&subcommand)
(let ((*verbose* verbose))
(defmain:subcommand)))


(defcommand (main generate) ((source-dir "A with site's source files."
:default (namestring
(uiop:ensure-directory-pathname
*default-pathname-defaults*)))
(output-dir "An output directory to write HTML files to."
:default (namestring
(uiop:ensure-directory-pathname
(merge-pathnames "stage")))))
"Generates HTML static site from the source files."
(let ((source-dir (uiop:ensure-directory-pathname
source-dir))
(output-dir (uiop:ensure-directory-pathname
output-dir)))
(unless (probe-file (merge-pathnames ".staticlrc"
source-dir))
(format *standard-output*
"Config file .staticlrc is missing from the ~A directory.~%"
(namestring source-dir))
(uiop:quit 1))

(stage :root-dir source-dir
:stage-dir output-dir)
(when *verbose*
(format t "Site was written to: ~A~%"
(namestring output-dir)))))

0 comments on commit 7574ac9

Please sign in to comment.