Skip to content

Commit 57e85e3

Browse files
committed
[impr/print-all] Support --print-all flag
1 parent d5fa965 commit 57e85e3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmd/hcron/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var (
2020
fDayOfWeekStartsAtOne bool
2121
fUse24HourTimeFormat bool
2222
fVerbose bool
23+
fPrintAll bool
2324
fVersion bool
2425
fHelp bool
2526

@@ -32,6 +33,7 @@ func init() {
3233
flag.BoolVar(&fDayOfWeekStartsAtOne, "dow-starts-at-one", false, "Is day of the week starts at 1 (Monday-Sunday: 1-7)")
3334
flag.BoolVar(&fUse24HourTimeFormat, "24-hour", false, "Output description in 24 hour time format")
3435
flag.BoolVar(&fVerbose, "verbose", false, "Output description in verbose format")
36+
flag.BoolVar(&fPrintAll, "print-all", false, "Print all lines which is not a valid cron")
3537
flag.BoolVar(&fVersion, "v", false, "Print app version then exit")
3638
flag.BoolVar(&fHelp, "h", false, "Print help then exit")
3739
}
@@ -171,11 +173,17 @@ func stream(exprDesc *cron.ExpressionDescriptor, locType cron.LocaleType, reader
171173

172174
func normalize(line string) (expr string, remainder string) {
173175
if strings.HasPrefix(line, "#") {
176+
if fPrintAll {
177+
fmt.Printf("%s\n", line)
178+
}
174179
return "", line
175180
}
176181

177182
parts := strings.Fields(line)
178183
if len(parts) < 5 {
184+
if fPrintAll {
185+
fmt.Printf("%s\n", line)
186+
}
179187
return "", line
180188
}
181189

0 commit comments

Comments
 (0)