enry icon indicating copy to clipboard operation
enry copied to clipboard

Support detecting a language from content only

Open CodeMyst opened this issue 5 years ago • 5 comments

Looks like the CLI version doesn't support detecting a language from just content, but the main repo does.

CodeMyst avatar May 26 '20 15:05 CodeMyst

Thank you for the suggestion!

Do you have an example in mind, how do you think this should work with the CLI interface?

bzz avatar May 29 '20 21:05 bzz

Providing a simple CLI option and providing the code through either a file or stdin (or allowing both).

CodeMyst avatar May 29 '20 21:05 CodeMyst

Yes it seems it doesn't support https://github.com/go-enry/go-enry/#by-text . Actually I guess currently only guessing by extension is supported by the tool.
There is a -mode option but it seems doesn't change the outcome.
To test, copy a C file and change its extension to py or go. enry detects py and go respectively. Even when the file has no extension, none of the -mode options report anything other than text

pvonmoradi avatar Jan 17 '21 10:01 pvonmoradi

I was looking at your change at https://github.com/jeremy-jameson/enry/commit/b7a5521727fd042bd095c7fea1fd7de65e91578d since I also need to detect by text. I ended up testing your build on Windows, and it's almost working for my purposes. However, I need to add a few more languages to your list, and I'm struggling to understand how to build it. Any pointers would be much appreciated.

gregnis avatar Dec 09 '22 19:12 gregnis

I'm struggling to understand how to build it.

Usually, running go build . from the checkout is enough. And, indeed, creating a custom binary that supports your use case is the simplest way to go.

bzz avatar Dec 22 '22 17:12 bzz