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.lua15
1 files changed, 12 insertions, 3 deletions
diff --git a/lua/aotrix/build.lua b/lua/aotrix/build.lua
index 91b2504..e1fd061 100644
--- a/lua/aotrix/build.lua
+++ b/lua/aotrix/build.lua
@@ -29,9 +29,17 @@ local readJsonFromFile = function(filePath)
return nil
end
-local addCommandToJsonFile = function(command, commandsFilePath, directory)
+local addCommandToJsonFile = function(commandBlock, commandsFilePath, directory)
local current_json = readJsonFromFile(commandsFilePath)
- current_json["hihi"] = 2
+ if current_json ~= nil then
+ if current_json[directory] == nil then
+ current_json[directory] = {}
+ end
+ table.insert(current_json[directory], {
+ command = tostring(commandBlock.command()),
+ description = tostring(commandBlock.description())
+ })
+ end
local file, error = io.open(commandsFilePath, 'w')
if file then
local indent = vim.bo.expandtab and (' '):rep(vim.o.shiftwidth) or '\t'
@@ -63,7 +71,8 @@ local personalCommands = require("aotrix.personal_commands")
COMMANDS.AddCommand = {
command = function()
local created_command = personalCommands.createCommand(COMMANDS)
- addCommandToJsonFile(created_command, PERSONAL_COMMAND_JSON_PATH)
+ addCommandToJsonFile(created_command, PERSONAL_COMMAND_JSON_PATH,
+ vim.fn.getcwd())
CURRENT_COMMAND = created_command.command
return CURRENT_COMMAND()
end,