Skip to content
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
21 changes: 8 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,27 +112,20 @@ package main

import (
"fmt"
"log"

"github.com/Moderrek/lines/pkg/lines"
)

func main() {
// Configure the counter with default settings.
config := lines.Config{
IncludeHidden: false,
}
counter := lines.NewCounter(config)
counter := lines.NewCounter(lines.Config{})

// Run the analysis on the current directory.
result, err := counter.Run(".")
result, err := counter.Run([]string{"."})
if err != nil {
log.Fatalf("Analysis failed: %v", err)
fmt.Printf("error: %v\n", err)
}

// Print results.
for ext, count := range result.LinesByExtension {
fmt.Printf("Extension: %s, Lines: %d\n", ext, count)
fmt.Printf("ext: %s\tlines: %d\n", ext, count)
}
}
```
Expand All @@ -145,10 +138,12 @@ You can customize which directories and file extensions to ignore:
config := lines.Config{
IncludeHidden: false,
IgnoredDirs: lines.IgnoredDirSet("node_modules", ".git"),
IgnoredExtensions: lines.IgnoredExtensionSet("exe", ".env"),
IgnoredExtensions: lines.IgnoredExtensionSet("exe", "env"),
NumWorkers: 4,
Verbose: true,
}
counter := lines.NewCounter(config)
result, err := counter.Run("./src")
result, err := counter.Run([]string{"./src"})
```

If `IgnoredDirs` or `IgnoredExtensions` are not provided, the library uses sensible defaults. The helper functions above are optional, but they make the config easier to read.
Expand Down
Loading