arosspope / src2pdf

Generate a pdf report of your source code using bash and LaTeX.
MIT License
26 stars 8 forks source link

Infer source files and language thereof #2

Open alis0nc opened 6 years ago

alis0nc commented 6 years ago

Perhaps something could be done with running file(1) on the whole directory to pick up what files are source files (as opposed to plain old text) and their language, instead of asking the user for the project language and source file extensions.

alis0nc commented 6 years ago

That does introduce a dependency on file(1) though, and your distribution's magic files, so it could lead to different behaviour on different Unixen.

arosspope commented 6 years ago

Whilst I do think that this idea has merit, it would mean we would need to maintain some kind of mapping between file extensions, the output of file(1) and the languages the LaTeX source listings package knows about. Additionally (whilst it probably only applies to c/c++ and perhaps a moot point) some file extensions map to multiple languages, so it might be somewhat difficult to infer the desired language of the overall project.

If you can propose a method to overcome/implement this functionality, then I would be interested to hear it. Otherwise, I think letting the user choose the language makes the script simple and is the best path for now.