[Feature Request]: Other options from curl like "--resolve"
Closed this issue · 6 comments
Since this is called "curl", could it be possible to have a collection of commands that are outside of the normal scope?
For example:
URL=some_url
PORT=443
IP=some_ip
curl https://"$URL" --resolve "$URL":"$PORT":"$IP"
At the moment it says: curl: (49) Couldn't parse CURLOPT_RESOLVE entry '::'
Hi, I saw you closed this issue, but wanted to mention that I do want to do something like this, so you can define variables in the file instead. However, environment variables should work, so if you have set some global ones then they should work with curl.nvim. I am not sure if it reads from your current shell session (maybe), but I can also try and make that work.
Yes that’s why I closed the issue, I just use the env variables now. But it would also be cool to have the env variables inside the file so I can have “troubleshoot”, “post” etc as custom tabs but also globally. So yeah thanks for this plugin already! I’m looking forward to the future of it.
Right, so variables are scoped to the the file itself. Immidately thinking of maybe a metadata field, like in markdown/obsidian, at the top which is seperated by i.e. ---
Then you could also specify hostname.
Would make it closer to HTTP specs maybe like in jetbrains, but still compatible with curl flags.
Thanks for using the plugin and providing feedback!
Also realizing I should have an option to scope custom buffers, so you can have a set of curl command files for each project.
This in ftplugin seems to work for me, note i'm no developer so it's probably too dirty :)
vim.notify = require("notify")
local current_dir = vim.fn.getcwd()
local file_path = current_dir .. "/.env.curl"
local my_env_table = {}
local function read_and_set_env_vars(env_file)
local file = io.open(env_file, "r") -- r read mode
if not file then
vim.notify("No .env.curl file found", vim.log.levels.INFO)
return nil
end
for line in file:lines() do
-- Match lines of the form VAR=value or VAR="value"
local key, value = string.match(line, "([^=]+)=[\"']?(.-)[\"']?$")
if key and value then
vim.env[key] = value
table.insert(my_env_table, key)
end
end
file:close()
vim.notify("Loading env variables:" .. "\n" .. table.concat(my_env_table, "\n"), vim.log.levels.INFO)
end
read_and_set_env_vars(file_path)
@bertverbessem Awesome, thanks! I will draw some inspiration from that when I get to #12