gatherCrontabs collects crontabs from the specified args or the default locations.
(args []string)
| 59 | |
| 60 | // gatherCrontabs collects crontabs from the specified args or the default locations. |
| 61 | func gatherCrontabs(args []string) []*lib.Crontab { |
| 62 | var username string |
| 63 | if u, err := user.Current(); err == nil { |
| 64 | username = u.Username |
| 65 | } |
| 66 | |
| 67 | crontabs := []*lib.Crontab{} |
| 68 | |
| 69 | if len(args) > 0 { |
| 70 | if isPathToDirectory(args[0]) { |
| 71 | crontabs = lib.ReadCrontabsInDirectory(username, args[0], crontabs) |
| 72 | } else { |
| 73 | crontabs = lib.ReadCrontabFromFile(username, args[0], crontabs) |
| 74 | } |
| 75 | } else { |
| 76 | users := parseUsers() |
| 77 | if len(users) == 0 { |
| 78 | users = []string{username} |
| 79 | } |
| 80 | |
| 81 | for _, user := range users { |
| 82 | crontabs = lib.ReadCrontabFromFile(user, fmt.Sprintf("user:%s", user), crontabs) |
| 83 | } |
| 84 | crontabs = lib.ReadCrontabFromFile(username, lib.SYSTEM_CRONTAB, crontabs) |
| 85 | crontabs = lib.ReadCrontabsInDirectory(username, lib.DROP_IN_DIRECTORY, crontabs) |
| 86 | } |
| 87 | |
| 88 | return crontabs |
| 89 | } |
| 90 | |
| 91 | // jobLines returns only the lines that have a command to run. |
| 92 | func jobLines(crontab *lib.Crontab) []*lib.Line { |
no test coverage detected