6464 termDimFG = lterm .Fg8 (240 )
6565)
6666
67+ var configRoot string
68+
6769type CLI struct {
6870 Check struct {
6971 Paths []string `arg:"" name:"paths" help:"directories to check"`
@@ -113,22 +115,23 @@ type CLI struct {
113115 Version struct {
114116 } `cmd:"" help:"show version information"`
115117
116- LogDeleted bool `short:"x" help:"log deleted/missing files/directories since the last run" negatable:""`
117- IncludeDot bool `short:"d" help:"include dot files" negatable:""`
118- SkipSymlinks bool `short:"S" help:"do not follow symlinks" negatable:""`
119- NoRecurse bool `short:"R" help:"do not recurse into subdirectories" negatable:""`
120- NoDirInIndex bool `short:"D" help:"do not track directories in the index" negatable:""`
121- NoConfig bool `help:"ignore the config file"`
122- MaxDepth int `default:0 help:"process a directory only if it is N or fewer levels below the specified path(s); 0 for no limit"`
123- LogFile string `short:"l" help:"write to a logfile if specified"`
124- LogVerbose bool `help:"verbose logging" negatable:""`
125- Algo string `default:"blake3" help:"hash algorithm: md5, sha512, blake3"`
126- IndexName string `default:".chkbit" help:"filename where chkbit stores its hashes, needs to start with '.'"`
127- IgnoreName string `default:".chkbitignore" help:"filename that chkbit reads its ignore list from, needs to start with '.'"`
128- Workers int `short:"w" default:"5" help:"number of workers to use. For slow IO (like on a spinning disk) --workers=1 will be faster"`
129- Plain bool `help:"show plain status instead of being fancy" negatable:""`
130- Quiet bool `short:"q" help:"quiet, don't show progress/information" negatable:""`
131- Verbose bool `short:"v" help:"verbose output" negatable:""`
118+ LogDeleted bool `short:"x" help:"log deleted/missing files/directories since the last run" negatable:""`
119+ IncludeDot bool `short:"d" help:"include dot files" negatable:""`
120+ SkipSymlinks bool `short:"S" help:"do not follow symlinks" negatable:""`
121+ NoRecurse bool `short:"R" help:"do not recurse into subdirectories" negatable:""`
122+ NoDirInIndex bool `short:"D" help:"do not track directories in the index" negatable:""`
123+ NoConfig bool `help:"do not load the config file"`
124+ NoGlobalIgnore bool `help:"do not load the global ignore file"`
125+ MaxDepth int `default:0 help:"process a directory only if it is N or fewer levels below the specified path(s); 0 for no limit"`
126+ LogFile string `short:"l" help:"write to a logfile if specified"`
127+ LogVerbose bool `help:"verbose logging" negatable:""`
128+ Algo string `default:"blake3" help:"hash algorithm: md5, sha512, blake3"`
129+ IndexName string `default:".chkbit" help:"filename where chkbit stores its hashes, needs to start with '.'"`
130+ IgnoreName string `default:".chkbitignore" help:"filename that chkbit reads its ignore list from, needs to start with '.'"`
131+ Workers int `short:"w" default:"5" help:"number of workers to use. For slow IO (like on a spinning disk) --workers=1 will be faster"`
132+ Plain bool `help:"show plain status instead of being fancy" negatable:""`
133+ Quiet bool `short:"q" help:"quiet, don't show progress/information" negatable:""`
134+ Verbose bool `short:"v" help:"verbose output" negatable:""`
132135}
133136
134137type CLIDedup struct {
@@ -338,6 +341,9 @@ func (m *Main) runCmd(command string, cli CLI) int {
338341 m .context .SkipSubdirectories = cli .NoRecurse
339342 m .context .TrackDirectories = ! cli .NoDirInIndex
340343 m .context .MaxDepth = cli .MaxDepth
344+ if ! cli .NoGlobalIgnore {
345+ m .context .GlobalIgnorePath = configRoot
346+ }
341347
342348 st , root , err := chkbit .LocateIndex (pathList [0 ], chkbit .IndexTypeAny , m .context .IndexFilename )
343349 if err != nil {
@@ -461,9 +467,8 @@ func (m *Main) run() int {
461467 }
462468
463469 var configPath = "chkbit-config.json"
464- configRoot , err := os .UserConfigDir ()
465- if err == nil {
466- configPath = slpath .Join (configRoot , "chkbit/config.json" )
470+ if configRoot != "" {
471+ configPath = slpath .Join (configRoot , "config.json" )
467472 }
468473
469474 var cli CLI
@@ -595,7 +600,14 @@ func (m *Main) run() int {
595600 return 0
596601
597602 case cmdTips :
598- fmt .Println (strings .ReplaceAll (helpTips , "<config-file>" , configPath ))
603+ globalIgnoreFile := "unsupported"
604+
605+ if configRoot != "" {
606+ globalIgnoreFile = slpath .Join (configRoot , cli .IgnoreName )
607+ }
608+ tips := strings .ReplaceAll (helpTips , "<config-file>" , configPath )
609+ tips = strings .ReplaceAll (tips , "<global-ignore-file>" , globalIgnoreFile )
610+ fmt .Println (tips )
599611 return 0
600612 case cmdVersion :
601613 fmt .Println ("github.com/laktak/chkbit" )
@@ -616,6 +628,13 @@ func main() {
616628 }
617629 }()
618630
631+ var err error
632+ if configRoot , err = os .UserConfigDir (); err == nil {
633+ configRoot = slpath .Join (configRoot , "chkbit" )
634+ } else {
635+ configRoot = ""
636+ }
637+
619638 termWidth := lterm .GetWidth ()
620639 m := & Main {
621640 logger : log .New (io .Discard , "" , 0 ),
0 commit comments