documented safe value and plural functions in the README

This commit is contained in:
Manuel Carmona 2017-07-07 09:59:56 +02:00
parent c41038d444
commit b2d0e5935b

View File

@ -22,15 +22,15 @@ Examples
--------
```go
lang, _ := GetLanguageByExtension("foo.go")
lang, safe := enry.GetLanguageByExtension("foo.go")
fmt.Println(lang)
// result: Go
lang, _ = GetLanguageByContent("foo.m", "<matlab-code>")
lang, safe := enry.GetLanguageByContent("foo.m", "<matlab-code>")
fmt.Println(lang)
// result: Matlab
lang, _ = GetLanguageByContent("bar.m", "<objective-c-code>")
lang, safe := enry.GetLanguageByContent("bar.m", "<objective-c-code>")
fmt.Println(lang)
// result: Objective-C
@ -38,6 +38,21 @@ fmt.Println(lang)
lang := enry.GetLanguage("foo.cpp", "<cpp-code>")
```
Note the returned boolean value "safe" is set either to true, if there is only one possible language detected or, to false otherwise.
To get a list of possible languages for a given file, you can use the plural version of the detecting functions.
```go
langs := enry.GetLanguages("foo.h", "<cpp-code>")
// result: []string{"C++", "C"}
langs := enry.GetLanguagesByExtension("foo.asc", "<content>", nil)
// result: []string{"AGS Script", "AsciiDoc", "Public Key"}
langs := enry.GetLanguagesByFilename("Gemfile", "<content>", []string{})
// result: []string{"Ruby"}
```
CLI
-----------------