src-d / enry

A faster file programming language detector
https://blog.sourced.tech/post/enry/
Apache License 2.0
460 stars 51 forks source link

Not handling extensions #249

Open maxpv opened 5 years ago

maxpv commented 5 years ago

After noticing that enry commands ignore files without extension, I Wrote a simple PHP file:

<?php 
    echo "Hello";
?>

Created files with the same content but different extensions:

.
├── hello.c
├── hello.css
├── hello.html
└── hello.sql

enry --breakdown returns:

39.02%  CSS
30.49%  C
30.49%  HTML

C
hello.c
CSS
hello.css
HTML
hello.html

Don't know if that's the desired output.

bzz commented 5 years ago

Hi @maxpv this is the desired output at the current state due to the fact the enry works the same way as https://github.com/github/linguist#how-linguist-works

Basically you either need to specifically call a library API that would always check the content for possible (ambiguous) list of matching languages (e.g GetLanguageByClassifier or GetLanguageByContent that do not depend on file extension), otherwise if used though a high-level API - the first unambiguous strategy will be used, as it is done by CLI which in this case was a file extension.

I'll push a bit of the doc update on use cases, to make more clear soon.

bzz commented 4 years ago

Updated docs available at https://github.com/go-enry/go-enry#use-cases