// Simple example always updates the config when file changes are detected. func simple(parser *args.ArgParser) args.WatchCancelFunc { // Get our current config appConf := parser.GetOpts() configFile := appConf.String("config-file") // Watch the file every time.Second and call func(err error){} when the file is modified cancelWatch, err := args.WatchFile(configFile, time.Second, func(err error) { if err != nil { fmt.Printf("Watch Error %s\n", err.Error()) return } // You can safely ignore the returned Options{} object here. // the next call to GetOpts() from within the handler will // pick up the newly parsed config appConf, err = parser.FromINIFile(configFile) if err != nil { fmt.Printf("Failed to load updated config - %s\n", err.Error()) return } }) if err != nil { fmt.Printf("Unable to start watch '%s' - %s", configFile, err.Error()) } return cancelWatch }