This thread contains a patchset. You're looking at the original emails,
but you may wish to use the patch review UI.
Review patch
3
2
[PATCH mnc v2 0/2] Adding a couple of command line flags
I added a few command line flags that I found useful. Submitting them
here in case you do to.
Thanks!
jpfeiffer16 (2):
add human readable and absolute options
println, not print
mnc.go | 40 +++++++++++++++++++++++++++++-----------
1 file changed, 29 insertions(+), 11 deletions(-)
--
2.45.2
[PATCH mnc v2 1/2] add human readable and absolute options
From: jpfeiffer16 <joepfeiffer16@gmail.com>
- Human readable outputs default formatted date-time
- Absolute outputs the date-time of the next cronjob instead of
time-till interval.
- Change deprecated call to ioutils. use io instead.
---
mnc.go | 40 +++++++++++++++++++++++++++++ -----------
1 file changed, 29 insertions(+), 11 deletions(-)
diff --git a/mnc.go b/mnc.go
index 43b8b2b..099b300 100644
--- a/mnc.go
+++ b/mnc.go
@@ -4,7 +4,7 @@ import (
"bufio"
"flag"
"fmt"
- "io/ioutil"
+ "io"
"log"
"os"
"strings"
@@ -13,13 +13,17 @@ import (
"github.com/influxdata/cron"
)
+ var absolute *bool;
+ var human *bool;
+
func init() {
- verbose := flag.Bool("v", false, "display log output")
+ verbose := flag.Bool("v", false, "display log output")
+ absolute = flag.Bool("a", false, "display absolute time for next cron job")
+ human = flag.Bool("r", false, "display time in human readable format")
flag.Parse()
- if *verbose {
- } else {
- log.SetOutput(ioutil.Discard)
+ if !*verbose {
+ log.SetOutput(io.Discard)
log.SetFlags(0)
}
}
@@ -41,16 +45,30 @@ func main() {
if e != nil {
log.Fatal(e)
}
- i := int(t.Sub(n).Seconds())
- if i < m {
- m = i
+ if *absolute {
+ if *human {
+ fmt.Print(t.String())
+ } else {
+ fmt.Print(t.Unix())
+ }
+ } else {
+ delta := t.Sub(n);
+ if *human {
+ fmt.Print(delta.String())
+ } else {
+ i := int(delta.Seconds())
+ if i < m {
+ m = i
+ }
+ log.Print(i)
+ fmt.Println(m)
+ }
}
- log.Print(i)
} else {
- log.Print(e)
+ log.Fatal(e)
+ fmt.Println(m)
}
}
- fmt.Println(m)
}
--
2.45.2
[PATCH mnc v2 2/2] println, not print
From: jpfeiffer16 <joepfeiffer16@gmail.com>
---
mnc.go | 8 ++++ ----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mnc.go b/mnc.go
index 099b300..17ddd87 100644
--- a/mnc.go
+++ b/mnc.go
@@ -47,20 +47,20 @@ func main() {
}
if *absolute {
if *human {
- fmt.Print(t.String())
+ fmt.Println(t.String())
} else {
- fmt.Print(t.Unix())
+ fmt.Println(t.Unix())
}
} else {
delta := t.Sub(n);
if *human {
- fmt.Print(delta.String())
+ fmt.Println(delta.String())
} else {
i := int(delta.Seconds())
if i < m {
m = i
}
- log.Print(i)
+ log.Println(i)
fmt.Println(m)
}
}
--
2.45.2
Hey, this seems like a patchset that is an earlier version of another
patchset in this mailing list. I am marking this patchset as superseded. Please
ping me in irc (my nick is anjan) if I am mistaken.
Thank you for your contribution.
Best,
Anjandev Momi