anordal / shellharden

The corrective bash syntax highlighter
Mozilla Public License 2.0
4.62k stars 129 forks source link

Separate out into a library? #33

Open sunshowers opened 4 years ago

sunshowers commented 4 years ago

Hi there!

shellharden looks fantastic, and I was considering integrating it into some lint infrastructure we have. However, it looks like the only stable interface is a binary. Would you consider separating out the checks into a library and providing a Rust API as well?

A bonus would be if you could read files from memory rather than the file system -- perhaps via a trait that specifies how files should be read.

I do something similar for a tool I'm the primary author of, cargo-guppy, where there's both a Rust interface (guppy) and a CLI tool (cargo-guppy).

Thank you!

anordal commented 3 years ago

I could do this if there is a compelling use case.

A minor concern is that the inner interface is rather low-level and would seem clumsy to a developer that is not performance obsessed (it is a state machine that reads a buffer and returns its progress and any alternative text). What this should be suitable for is IDE integration.

The bigger concern is that Shellharden is an expert at breaking scripts, and that everyone who hasn't read the warning about that would think it was a bug, and not the deal about using it. It is important to tell end users about the alternative ways of doing things that gets you out of these situations. After all, it comes with a manual. This is again a bit use case dependent.

For lint purposes – the domain of ShellCheck – I normally recommend that. I'm not trying to compete with it.

Thanks for the encouragement!