jackMort / ChatGPT.nvim

ChatGPT Neovim Plugin: Effortless Natural Language Generation with OpenAI's ChatGPT API
Apache License 2.0
3.56k stars 307 forks source link

`api_key_cmd` won't work if command argument contain spaces #367

Open traysh opened 6 months ago

traysh commented 6 months ago

I get Config api_key_cmd did not return a value when executed when using the following config:

require("chatgpt").setup({
    api_key_cmd = "/usr/bin/secret-tool lookup Path 'OpenAI API Key - chatGPT.nvim'"
})

But looking up a key that doesn't contain spaces works:

require("chatgpt").setup({
    api_key_cmd = "/usr/bin/secret-tool lookup Uuid 112c0e39f57244d4b25fed63c68b7c65"
})

Please note the 2 commands above lookup the same entry and both work on the terminal. Therefore, parsing api_key_cmd does not work when arguments contain spaces, such as 'OpenAI API Key - chatGPT.nvim'. The problem probably lies in this function.