changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / lisp/bin/organ.lisp

changeset 698: 96958d3eb5b0
parent: 2e7d93b892a5
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 22:04:59 -0400
permissions: -rw-r--r--
description: fixes
1 ;;; organ.lisp --- Org-mode utility
2 
3 ;;
4 
5 ;;; Code:
6 (defpackage :bin/organ
7  (:use :cl :organ :std :cli :log :clap))
8 
9 (in-package :bin/organ)
10 (defopt organ-help (print-help *cli*))
11 (defopt organ-version (print-version *cli*))
12 (defopt organ-log-level (setq *log-level* (if *arg* t :info)))
13 ;; (defopt organ-output (when *arg* (trace! (or *arg* "output.organ"))))
14 (defcmd organ-describe
15  (if *args*
16  ;; TODO typed args
17  (describe (org-parse :document (pathname (car *args*))))
18  (describe (org-parse :document #P"readme.org"))))
19 
20 (defcmd organ-inspect
21  (if *args*
22  ;; TODO typed args
23  (inspect (org-parse :document (pathname (car *args*))))
24  (inspect (org-parse :document #P"readme.org"))))
25 
26 (defcmd organ-show
27  (if *args*
28  (print (org-parse-lines t (uiop:read-file-string (car *args*))))
29  (error! "missing file arg")))
30 
31 (defcmd organ-parse
32  (let ((input (if *args* (car *args*) #P"readme.org")))
33  (describe (org-parse :document input))))
34 
35 (define-cli *organ-cli*
36  :name "organ"
37  :version "0.0.1"
38  :description "org-mode toolbox"
39  :thunk 'organ-describe
40  :opts ((:name "level" :description "set the log level" :thunk organ-log-level)
41  (:name "help" :description "print help" :thunk organ-help)
42  (:name "version" :description "print version" :thunk organ-version)
43  ;; (:name "output" :description "output file" :kind file :thunk organ-output)
44  )
45  :cmds ((:name inspect
46  :description "inspect an org file"
47  :thunk organ-inspect)
48  (:name show
49  :description "display local org info"
50  :thunk organ-show)
51  (:name describe
52  :description "describe local org info"
53  :thunk organ-describe)
54  (:name parse
55  :thunk organ-parse)))
56 
57 (defun run ()
58  (let ((*log-level* :info))
59  (with-cli (*organ-cli* opts cmds args) (cli:args)
60  (do-cmd *cli*)
61  (debug-opts *cli*))))
62 
63 (defmain start-organ ()
64  (run))