Skip to content

Commit

Permalink
refactor(api): get_rocks_toml -> get_rocks_toml_path
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed Dec 12, 2023
1 parent b7e096b commit 0d79098
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lua/rocks/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@

local api = {}

local nio = require("nio")
local cache = require("rocks.cache")
local luarocks = require("rocks.luarocks")
local fzy = require("rocks.fzy")
local state = require("rocks.state")
local commands = require("rocks.commands")
local config = require("rocks.config.internal")
local constants = require("rocks.constants")
local fs = require("rocks.fs")
local fzy = require("rocks.fzy")
local luarocks = require("rocks.luarocks")
local nio = require("nio")
local state = require("rocks.state")

---Tries to get the cached rocks.
---Returns an empty list if the cache has not been populated
Expand Down Expand Up @@ -91,11 +93,19 @@ end

---Gets the rocks.toml file path.
---Note that the file may not have been created yet.
---@return string rocks_toml_file
function api.get_rocks_toml()
---@return string rocks_toml_file_path
function api.get_rocks_toml_path()
return config.config_path
end

---Returns a table with the parsed rocks.toml file.
---If the file doesn't exist a file with the default configuration will be created.
---@return table rocks_toml_file
function api.get_rocks_toml()
local config_file = fs.read_or_create(config.config_path, constants.DEFAULT_CONFIG)
return require("toml").decode(config_file)
end

---@class RocksCmd
---@field impl fun(args:string[]) The command implementation
---@field complete? fun(subcmd_arg_lead: string): string[] Command completions callback, taking the lead of the subcommand's arguments
Expand Down

0 comments on commit 0d79098

Please sign in to comment.