-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to run command before request #78
Comments
A recent PR has added an ability to read an env variable. Do you think it works (though how the env variable is set is outside VRC)? |
i create pr for pipe option, you can pull from it |
Ended up with something like this: function RunWithPreCommand()
local pre = vim.fn.findfile('pre.sh', '.;')
if pre ~= '' then
vim.fn.system('bash ' .. pre)
end
vim.cmd('call VrcQuery()')
end
MAPKEY('n', '<leader>r', ':lua RunWithPreCommand()<CR>', { noremap = true, silent = true }) It runs authentication code which resides in pre.sh: #!/bin/bash
REFRESH_KEY=XXXXXXXX
URL=https://www.my/auth/provider/verifyPassword?key=$REFRESH_KEY
HEADER="Content-Type: application/json"
BODY='{"email": "[email protected]", "password": "123456", "returnSecureToken": true}'
IDTOKEN=$(curl --silent -X POST -H "$HEADER" -d "$BODY" $URL | jq -r '.token')
sed -i "s/X-AUTH:.*$/X-AUTH: Token $IDTOKEN/" api/headers So, it looks for a bash script in the project's directory, and executes it exporting the output to a headers file. Then you can execute all your queries reading the headers from this file, like so:
Hope this helps. o/ |
this would be useful to get an auth token
I'm thinking about something:
a way to pipe the curl output would be also usefull - when the return value is long it's hard to check it in vim - piping to jq or tail could be interesting
The text was updated successfully, but these errors were encountered: