Skip to content
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

Expose C++ API interface #19

Open
robertrossmann opened this issue Oct 5, 2017 · 3 comments
Open

Expose C++ API interface #19

robertrossmann opened this issue Oct 5, 2017 · 3 comments

Comments

@robertrossmann
Copy link

It would be a great feature to implement some kind of programmatic API to check an SQL file (either from path or from the contents given as argument) so that 3rd party tools can be built around sqlcheck.

My primary interest is to integrate this tool into an editor/IDE for SQL file linting. Currently the only way to integrate this tool into an editor would be to run shellcheck as a standard command invocation from shell and parse the output, then map it to the lines and character positions. This approach is not very performant and would require a lot of work, especially in the output parsing logic. However, creating a stanard way to programmatically invoke shellcheck would work perfectly for this use case.

Unfortunately I am not proficient enough in C/C++ to send a PR, so leaving this here as a suggestion only. Thank you for considering this feature!

@jarulraj
Copy link
Owner

jarulraj commented Oct 8, 2017

@robertrossmann Thanks for the feedback! This tool actually is a wrapper around a C++ library (sqlcheck_library) that exposes a programmatic API to check an SQL file. You can integrate the sqlcheck_library into an editor.

https://github.com/jarulraj/sqlcheck/blob/master/src/CMakeLists.txt#L13
https://github.com/jarulraj/sqlcheck/blob/master/src/CMakeLists.txt#L17

@robertrossmann
Copy link
Author

Thanks @jarulraj for your tip! I would definitely use that function to integrate this tool into an editor, however what worries me is that function's output - it's just stdout! This makes mapping the results back to the code in the editor rather difficult.

The optimal interface of that function would be that I give it a string with the SQL and it gives me back some data structure (ie. an array?) with the errors and their position in the string. This way I could format the results for display in any way I need. I could even show a marker in the editor.

This will most likely be a non-trivial task should you decide to adopt it. However, I would be ever so grateful! Thanks!

@jarulraj
Copy link
Owner

I see, that's a helpful suggestion. I think that it should not be too hard.

I will give it a shot in the near future!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants