-
Notifications
You must be signed in to change notification settings - Fork 6
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
fix: not work in gitbash #39
fix: not work in gitbash #39
Conversation
@iamxiaojianzheng Thank you for finding the error, I really appreciate it! Do you want me to do it for you? |
I hope you can check again whether this change is reasonable. On your computer environment, try to see if this change is compatible. |
It worked on my machine, so the change is good :) You can see them here: https://github.com/oysandvik94/curl.nvim/actions/runs/10557596972/job/29245918019?pr=39 |
Sorry, I'm not familiar with unit testing. How should I handle this error? |
@iamxiaojianzheng Actually, I see one more issue: If you try to run:
Then you get an error: |
After thinking a little bit, I think the right way to do this is to built up the command table bit by bit, instead of creating a string that is then finally split. |
Yes, tested. I found that needed to parse curl's syntax and build a reasonable list of command arguments. |
I seem to have solved the problem of executing command. You tried to execute the
My guess is that the # bad
curl -X POST https://jsonplaceholder.typicode.com/posts
-H
'Content-Type: application/json'
-d
{ "title": "now try this" }
# good
curl -X POST https://jsonplaceholder.typicode.com/posts
-H 'Content-Type: application/json'
-d
{
"title": "now try this"
}
# good
curl -X POST https://jsonplaceholder.typicode.com/posts
-H 'Content-Type: application/json'
-d
{ "title": "now try this"
}
# good
curl -X POST https://jsonplaceholder.typicode.com/posts
-H 'Content-Type: application/json'
-d
'{"title": "now try this"}' |
I think maybe the "right" solution here is to rewrite the parse_curl_command function to parse all the components of the curl command in to elements in a table, but this requires a bigger rewrite. I think your solution is fine in the meantime. However, my worry here is that we need to support all shells. What would happen in this case if a user had fish? We should at least have a sensible default. See my comment in the PR. The tests are also failing due to the curl command being changed. If you need to run tests locally, run the "tests" script. From the root of the project, run: |
lua/curl/shell_utils.lua
Outdated
elseif M.has_powershell() then | ||
return { "powershell", "-Command" } | ||
else | ||
error("Shell not found: bash, sh, zsh, powershell.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just return an empty table here, so that we do a best effort attempt to run the command if a shell is not found?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried the {"curl xxxx"}
format and it doesn't seem to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it would be nice to highlight some of the shell notes in the README before the refactoring is complete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or for users with an unknown shell, can provide a configuration to be compatible with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we maybe say that if there's no found shell, it reverts to the previous behaviour?
I really don't want to have the plugin break for people because their shell is not defined in our code, when we don't actually need do anything for it to work.
Also, I dont think this plugin works with powershell since it relies on JQ, which I dont think can be installed in Powershell. This might give the impression that powershell is supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, if getting the shell fails, just execute the string as before, not the table.
Strange, might be OS related? I copied the busted file from folke's plugins. You'll see the test errors in the github action run of this PR. |
I think if you want to refactor, you can consider changing the design of the interactive UI. The current use and information presentation, I think a little too simple. I think you can look at |
@iamxiaojianzheng I'm happy with the default case here. There is only one test failure left, in "api_spec.lua". Line 13 should be: local mocked_jobstart = function(command, callback)
test_util.assert_equals(curl_command .. " -sSL", command[#command])
buffers.set_output_buffer_content(0, { "test" })
end As for your point on design/ux: This is definitely a minimalistic plugin compared to those you mention. It would be nice to get something more fancy in the future, but for now I am focusing on functionality and stability. When I get more time, I might invest more time in UX. |
I have modified |
All tests are passing and it looks good. Thank you so much for your contribution! |
about this #36