summaryrefslogtreecommitdiff
path: root/lua/aotrix/build.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/aotrix/build.lua')
-rw-r--r--lua/aotrix/build.lua27
1 files changed, 15 insertions, 12 deletions
diff --git a/lua/aotrix/build.lua b/lua/aotrix/build.lua
index c429467..35d9675 100644
--- a/lua/aotrix/build.lua
+++ b/lua/aotrix/build.lua
@@ -1,16 +1,19 @@
-local CURRENT_COMMAND = ""
+local CURRENT_COMMAND = nil
----@param command string
+---@param command string|nil
---@return nil
function executeCommandInTerminal(command)
- vim.cmd.term()
- vim.cmd.startinsert()
- local channel = vim.bo.channel
- -- 'clear' is used to hide the command
- local exit_message = "\nPress enter to exit..."
- vim.api.nvim_chan_send(channel,
- "clear && " .. command .. "; echo '" .. exit_message ..
- "' && read -s && exit" .. "\n")
+ if (command ~= nil) then
+ vim.cmd.term()
+ vim.cmd.startinsert()
+ local channel = vim.bo.channel
+ -- 'clear' is used to hide the command
+ local exitMessage = "\nPress enter to exit..."
+ local commandString = command()
+ vim.api.nvim_chan_send(channel,
+ "clear && " .. commandString .. "; echo '" ..
+ exitMessage .. "' && read -s && exit" .. "\n")
+ end
end
local COMMANDS = {}
@@ -29,14 +32,14 @@ function selectCommand(listOfCommands, callback)
end
}, function(choice)
if (choice ~= nil) then
- CURRENT_COMMAND = listOfCommands[choice].command()
+ CURRENT_COMMAND = listOfCommands[choice].command
callback()
end
end)
end
function executeCommand(listOfCommands)
- if (string.len(CURRENT_COMMAND) == 0) then
+ if (CURRENT_COMMAND == nil) then
selectCommand(listOfCommands,
function()
executeCommandInTerminal(CURRENT_COMMAND)