ignore files

This commit is contained in:
u80864958
2025-04-02 16:23:15 +02:00
parent abe9c7d1fb
commit 15f7db8d3e
10 changed files with 299 additions and 130 deletions

38
cmd/main.go Normal file
View File

@ -0,0 +1,38 @@
package main
import (
"flag"
"fmt"
"git.schreifuchs.ch/schreifuchs/pat/pkg/cat"
"git.schreifuchs.ch/schreifuchs/pat/pkg/ignore"
)
const DELEMITTER = "-(%s)--------------------------------------------------------------------------\n"
func main() {
ignorePath := flag.String("i", "", "set path to gitignore, if no gitignore parent dirs will be searched")
hiddenFiles := flag.Bool("h", false, "show hidden files")
flag.Parse()
cats, err := cat.Path(flag.Args()...)
if err != nil {
panic(err)
}
if *ignorePath != "" {
i, err := ignore.FindGitignore(*ignorePath)
if err != nil {
panic(err)
}
cats = cats.Ignored(i)
}
if *hiddenFiles == false {
cats = cats.Ignored(ignore.Filesystem{})
}
fmt.Print(cats.ToString(DELEMITTER))
}