add clog-tools:open-file and command line option

This commit is contained in:
David Botton 2024-05-12 11:52:54 -04:00
parent 2cf7ec9974
commit 74c22bd5dc
5 changed files with 21 additions and 6 deletions

2
README.md vendored
View file

@ -132,7 +132,7 @@ CL-USER> (ql:quickload :clog) ; if not already loaded
CL-USER> (clog:run-tutorial 1) CL-USER> (clog:run-tutorial 1)
``` ```
Tip for Windows WSL linux user. Install "sudo apt install xdg-utils" to Tip for Windows WSL linux user. Install "sudo apt install xdg-utils wslu" to
install xdg-open so that run-tutorial uses the windows browser. install xdg-open so that run-tutorial uses the windows browser.
To see where the source, tutorial and demo files are: To see where the source, tutorial and demo files are:

1
open-file vendored Executable file
View file

@ -0,0 +1 @@
sbcl --eval "(ql:quickload :clog/tools)" --eval "(clog-tools:clog-open \"$1\")"

1
open-file.bat vendored Executable file
View file

@ -0,0 +1 @@
sbcl --eval "(ql:quickload :clog/tools)" --eval "(clog-tools:clog-open \"%1\")"

View file

@ -16,6 +16,7 @@
(defpackage #:clog-tools (defpackage #:clog-tools
(:use #:cl #:clog #:clog-gui #:clog-web) (:use #:cl #:clog #:clog-gui #:clog-web)
(:export :clog-builder (:export :clog-builder
:clog-open
:add-supported-controls :add-supported-controls
:control-info :control-info
:clog-db-admin)) :clog-db-admin))

View file

@ -498,10 +498,6 @@ clog-builder window.")
(projects-load *start-project*)) (projects-load *start-project*))
(on-project-tree body :project *start-project*) (on-project-tree body :project *start-project*)
(when *start-dir* (when *start-dir*
(when *start-project*
(set-geometry (current-window body) :top 38 :left 5 :right "" :height "" :bottom 22)
(set-geometry (current-window body) :height (height (current-window body))
:bottom (bottom (current-window body))))
(handler-case (handler-case
(on-dir-win body :dir *start-dir*) (on-dir-win body :dir *start-dir*)
(error (msg) (error (msg)
@ -523,6 +519,22 @@ clog-builder window.")
(clog:shutdown) (clog:shutdown)
(uiop:quit)))) (uiop:quit))))
(defun clog-open (&optional open-file)
(unless (is-running-p)
(clog-builder :app t :port 0 :start-browser nil)
(sleep 1))
(let* ((open-loc (if (and (> (length open-file) 5)
(equal (subseq open-file (- (length open-file) 5)) ".clog"))
"/panel-editor?open-panel"
"/source-editor?open-file"))
(open-url (format nil "~A=~A"
open-loc (if (or (eq open-file nil)
(equal open-file ""))
"%20"
open-file))))
(format t "~%If browser does not start go to http://127.0.0.1:~A~A" clog:*clog-port* open-url)
(open-browser :url (format nil "http://127.0.0.1:~A~A" clog:*clog-port* open-url))))
(defun clog-builder (&key (port 8080) (start-browser t) (defun clog-builder (&key (port 8080) (start-browser t)
app project dir static-root system clogframe) app project dir static-root system clogframe)
"Start clog-builder. When PORT is 0 choose a random port. When APP is "Start clog-builder. When PORT is 0 choose a random port. When APP is