Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Added global flag for watching chmod only changes #33

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var (
flagDecoration string
decoration Decoration
verbose bool
chmods bool
globalFlags = flag.NewFlagSet("", flag.ContinueOnError)
globalConfig = &Config{}

Expand Down Expand Up @@ -65,6 +66,8 @@ func init() {
(or '-' to read the configuration from stdin).`)
globalFlags.BoolVarP(&verbose, "verbose", "v", false, `
Verbose mode: print out more information about what reflex is doing.`)
globalFlags.BoolVarP(&chmods, "chmods", "m", false, `
Includes watching chmod *only* events.`)
globalFlags.BoolVarP(&flagSequential, "sequential", "e", false, `
Don't run multiple commands at the same time.`)
globalFlags.StringVarP(&flagDecoration, "decoration", "d", "plain", `
Expand All @@ -75,7 +78,7 @@ func init() {
func anyNonGlobalsRegistered() bool {
any := false
walkFn := func(f *flag.Flag) {
if !(f.Name == "config" || f.Name == "verbose" || f.Name == "sequential" || f.Name == "decoration") {
if !(f.Name == "config" || f.Name == "verbose" || f.Name == "sequential" || f.Name == "decoration"|| f.Name == "chmods") {
any = any || true
}
}
Expand Down Expand Up @@ -139,7 +142,7 @@ func main() {
configs = []*Config{globalConfig}
} else {
if anyNonGlobalsRegistered() {
Fatalln("Cannot set other flags along with --config other than --sequential, --verbose, and --decoration.")
Fatalln("Cannot set other flags along with --config other than --sequential, --verbose, --decoration, and --chmods.")
}
var err error
configs, err = ReadConfigs(flagConf)
Expand Down
2 changes: 1 addition & 1 deletion watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func watch(root string, watcher *fsnotify.Watcher, names chan<- string, done cha
continue
}
path := normalize(e.Name, stat.IsDir())
if e.Op&chmodMask == 0 {
if !chmods && e.Op&chmodMask == 0 {
continue
}
names <- path
Expand Down