From 622e51b145666c67b2e92d4c6dd06bb81e259458 Mon Sep 17 00:00:00 2001 From: Saba Saba Date: Thu, 9 Feb 2023 12:26:20 -0500 Subject: [PATCH] Created a non-list version of git. --- git-repl.cl | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/git-repl.cl b/git-repl.cl index 4ecca4c..c46cfbf 100644 --- a/git-repl.cl +++ b/git-repl.cl @@ -37,16 +37,22 @@ "Removes every empty line from a list of lines of text" (remove-if #'str:emptyp text-lines)) -(defun run-command (command) - (remove-empty - (mapcar #'str:trim - (str:lines - (uiop:run-program command :ignore-error-status t :force-shell t :input nil :output :string) - :omit-nulls t)))) +(defun run-command (command &key (list-output t)) + (let ((output (uiop:run-program command :ignore-error-status t :force-shell t :input nil :output :string))) + (if list-output + (remove-empty (mapcar #'str:trim (str:lines output :omit-nulls t))) + output))) + +(defun-public run-git (arguments &key (list-output t)) + "Runs an arbitrary git command. Provide the list of arguments as a list of strings, for example: (run-git '(\"add\" \"-i\")) + When :list-output is set to T (default), the output is provided as a list of strings. + When :list-output is set to NIL, the raw output is provided as a single string. + To use :list-output, provide it after the argument as follows: (run-git '(\"add\" \"-i\") :list-output nil)" + (run-command (str:join " " (cons "git" arguments)) :list-output list-output)) (defun-public git (&rest arguments) "Runs an arbitrary git command. Separate each token as a string, for example: (git \"add\" \"-i\")" - (run-command (str:join " " (cons "git" arguments)))) + (run-git arguments)) (defun-public commands () "Lists every public command. Use (describe 'command-name) for documentation." -- 2.20.1