Skip to content

Commit

Permalink
[impr/print-all] Support --print-all flag
Browse files Browse the repository at this point in the history
  • Loading branch information
lnquy committed Nov 23, 2020
1 parent d5fa965 commit 57e85e3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/hcron/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var (
fDayOfWeekStartsAtOne bool
fUse24HourTimeFormat bool
fVerbose bool
fPrintAll bool
fVersion bool
fHelp bool

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

func normalize(line string) (expr string, remainder string) {
if strings.HasPrefix(line, "#") {
if fPrintAll {
fmt.Printf("%s\n", line)
}
return "", line
}

parts := strings.Fields(line)
if len(parts) < 5 {
if fPrintAll {
fmt.Printf("%s\n", line)
}
return "", line
}

Expand Down

0 comments on commit 57e85e3

Please sign in to comment.