Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Few enhancements in main file #12

Merged
merged 3 commits into from
Apr 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func main() {
jsonFlag := flag.Bool("json", false, "")
showVersion := flag.Bool("version", false, "Show the enry version information")
allLangs := flag.Bool("all", false, "Show all files, including those identifed as non-programming languages")
progLangs := flag.Bool("prog", false, "Show only files identifed as programming languages only")
progLangs := flag.Bool("prog", false, "Show files identifed as programming languages only")
countMode := flag.String("mode", "byte", "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)")
flag.Parse()
Expand Down Expand Up @@ -89,15 +89,14 @@ func main() {
if f.IsDir() {
return filepath.SkipDir
}

return nil
}

if f.IsDir() {
return nil
}

// TODO(bzz): provide API that mimics lingust CLI output for
// TODO(bzz): provide API that mimics linguist CLI output for
// - running ByExtension & ByFilename
// - reading the file, if that did not work
// - GetLanguage([]Strategy)
Expand Down Expand Up @@ -242,8 +241,10 @@ func fileCountValues(_ string, files []string) (float64, filelistError) {
}

func lineCountValues(root string, files []string) (float64, filelistError) {
var filesErr filelistError
var t float64
var (
filesErr filelistError
t float64
)
for _, fName := range files {
l, _ := getLines(filepath.Join(root, fName), nil)
t += float64(l)
Expand All @@ -252,8 +253,10 @@ func lineCountValues(root string, files []string) (float64, filelistError) {
}

func byteCountValues(root string, files []string) (float64, filelistError) {
var filesErr filelistError
var t float64
var (
filesErr filelistError
t float64
)
for _, fName := range files {
f, err := os.Open(filepath.Join(root, fName))
if err != nil {
Expand Down