3131; ;
3232; ;; Commentary:
3333; ; Provide a simple minibuffer completion interface to running Babashka tasks
34- ; ; for a project. Looks for bb.edn in the current directory or any of its
34+ ; ; for a project. Looks for bb.edn in the current directory or any of its
3535; ; parents, and if found and file contains :tasks provides user with menu to
3636; ; choose a task to run.
3737; ;
7272 (mapconcat #'shell-quote-argument (split-string s) " " ))
7373
7474(defun babashka--run-task (dir &optional do-not-recurse )
75- " Select a task to run from bb.edn in DIR or its parents. If
76- DO-NOT-RECURSE is passed and is not nil, don't search for bb.edn in
75+ " Select a task to run from bb.edn in DIR or its parents.
76+
77+ If DO-NOT-RECURSE is passed and is not nil, don't search for bb.edn in
7778DIR's parents."
7879 (if-let*
7980 ((bb-edn (if do-not-recurse
80- (let ((f (concat dir " /bb.edn" ))) (and (file-exists-p f) f))
81- (babashka--locate-bb-edn dir)
82- )))
81+ (let ((f (concat dir " /bb.edn" ))) (and (file-exists-p f) f))
82+ (babashka--locate-bb-edn dir)
83+ )))
8384 (let* ((bb-edn-dir (file-name-directory bb-edn))
8485 (tasks (babashka--get-tasks-hash-table bb-edn))
8586 (task-names (thread-last tasks hash-table-keys (mapcar #'symbol-name )))
@@ -93,33 +94,36 @@ DIR's parents."
9394 (babashka--run-shell-command-in-directory bb-edn-dir))
9495 (message " No tasks found in %s " bb-edn)))
9596 (message (if do-not-recurse
96- " No bb.edn found in directory."
97- " No bb.edn found in directory or any of the parents." ))))
97+ " No bb.edn found in directory."
98+ " No bb.edn found in directory or any of the parents." ))))
9899
99100;;;### autoload
100101(defun babashka-tasks (arg )
101102 " Run Babashka tasks for project or any path.
102103
103- Find bb.edn in current dir or its parents, and show a menu to select
104- and run a task. When called with interactive ARG prompts for directory."
104+
105+ Find bb.edn in current dir or its parents, and show a menu to select and run
106+ a task.
107+
108+ When called with interactive ARG prompts for directory."
105109 (interactive " P" )
106110 (let* ((dir (if arg
107- (read-file-name " Enter a path to bb.edn: " )
108- default-directory)))
111+ (read-file-name " Enter a path to bb.edn: " )
112+ default-directory)))
109113 (if dir
110114 (babashka--run-task dir)
111115 (message " Not in a file buffer. Run babashka-tasks when visiting one of your project's files. " ))))
112116
113117;;;### autoload
114118(defun babashka-project-tasks ()
115- " Run a Babashka task from the bb.edn file in the project's root
116- directory.
119+ " Run a Babashka task from the bb.edn file in the project's root directory.
120+
121+ This command is intended to be used as a `project-switch-project' command
122+ by adding it to `project-switch-commands' .
117123
118- This command is intended to be used as a `project-switch-project'
119- command by adding it to `project-switch-commands' . For example by
120- evaling:
124+ For example by evaling:
121125
122- (add-to-list \\= 'project-switch-commands
126+ \ ( add-to-list \\= 'project-switch-commands
123127 \\= '(babashka-project-tasks \" Babashka task\" \" t\" ))"
124128 (interactive )
125129 (thread-first
0 commit comments