mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-07-12 04:09:48 +00:00
cli: mimic linguist output by default
This includes next main changes: - default: print only Programming and Markup types as Linguist does - `-prog` option replaced with `-all`, to allow for previous behavior - always use GetLanguage as main source of truth that fixes #204 and perf will be restored under #212 Signed-off-by: Alexander Bezzubov <bzz@apache.org>
This commit is contained in:
@ -29,7 +29,7 @@ func main() {
|
|||||||
breakdownFlag := flag.Bool("breakdown", false, "")
|
breakdownFlag := flag.Bool("breakdown", false, "")
|
||||||
jsonFlag := flag.Bool("json", false, "")
|
jsonFlag := flag.Bool("json", false, "")
|
||||||
showVersion := flag.Bool("version", false, "Show the enry version information")
|
showVersion := flag.Bool("version", false, "Show the enry version information")
|
||||||
onlyProg := flag.Bool("prog", false, "Only show programming file types in output")
|
allLangs := flag.Bool("all", false, "Show not only the files with programming languages (default) but all languages instead")
|
||||||
countMode := flag.String("mode", "file", "the method used to count file size. Available options are: file, line and byte")
|
countMode := flag.String("mode", "file", "the method used to count file size. Available options are: file, line and byte")
|
||||||
limitKB := flag.Int64("limit", 16*1024, "Analyse first N KB of the file (-1 means no limit)")
|
limitKB := flag.Int64("limit", 16*1024, "Analyse first N KB of the file (-1 means no limit)")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
@ -96,24 +96,25 @@ func main() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
language, ok := enry.GetLanguageByExtension(path)
|
//TODO(bzz): provide API that mimics lingust CLI output for
|
||||||
if !ok {
|
// running ByExtension & ByFilename
|
||||||
if language, ok = enry.GetLanguageByFilename(path); !ok {
|
// reading the file, if that did not work
|
||||||
content, err := readFile(path, limit)
|
// GetLanguage([]Strategy)
|
||||||
if err != nil {
|
content, err := readFile(path, limit)
|
||||||
log.Println(err)
|
if err != nil {
|
||||||
return nil
|
log.Println(err)
|
||||||
}
|
return nil
|
||||||
|
|
||||||
language = enry.GetLanguage(filepath.Base(path), content)
|
|
||||||
if language == enry.OtherLanguage {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are displaying only prog. and language is not prog. skip it.
|
language := enry.GetLanguage(filepath.Base(path), content)
|
||||||
if *onlyProg && enry.GetLanguageType(language) != enry.Programming {
|
if language == enry.OtherLanguage {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we are displaying only prog, skip it
|
||||||
|
if !*allLangs &&
|
||||||
|
enry.GetLanguageType(language) != enry.Programming &&
|
||||||
|
enry.GetLanguageType(language) != enry.Markup {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user