84 lines
1.8 KiB
Go
84 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/urfave/cli/v2"
|
|
"gitnet.fr/deblan/expiration-check/checker"
|
|
"gitnet.fr/deblan/expiration-check/logger"
|
|
"gitnet.fr/deblan/expiration-check/render"
|
|
)
|
|
|
|
func NormalizeFormat(format string) string {
|
|
formats := []string{"json", "table", "csv", "tsv", "html", "markdown"}
|
|
|
|
for _, f := range formats {
|
|
if f == format {
|
|
return f
|
|
}
|
|
}
|
|
|
|
return "table"
|
|
}
|
|
|
|
func App() *cli.App {
|
|
flags := []cli.Flag{
|
|
&cli.StringSliceFlag{
|
|
Name: "domain",
|
|
Aliases: []string{"d"},
|
|
Required: true,
|
|
Usage: "list of domains",
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "format",
|
|
Aliases: []string{"f"},
|
|
Required: false,
|
|
Value: "table",
|
|
Usage: "output format: table, csv, tsv, html, json, markdown",
|
|
},
|
|
&cli.BoolFlag{
|
|
Name: "verbose",
|
|
Aliases: []string{"v"},
|
|
Required: false,
|
|
},
|
|
}
|
|
|
|
return &cli.App{
|
|
Usage: "Checks the expiration dates of domains and certificates",
|
|
HelpName: "expiration-check",
|
|
Commands: []*cli.Command{
|
|
{
|
|
Name: "certificate",
|
|
Aliases: []string{"c", "cert", "certs", "certificates"},
|
|
Usage: "Checks certificate",
|
|
Flags: flags,
|
|
Action: func(c *cli.Context) error {
|
|
logger.Get().SetVerbose(c.Bool("verbose"))
|
|
|
|
render.Render(
|
|
checker.CheckCertificates(c.StringSlice("domain")),
|
|
30, 14,
|
|
NormalizeFormat(c.String("format")),
|
|
)
|
|
|
|
return nil
|
|
},
|
|
},
|
|
{
|
|
Name: "domain",
|
|
Usage: "Checks domain expirations",
|
|
Aliases: []string{"d", "domains"},
|
|
Flags: flags,
|
|
Action: func(c *cli.Context) error {
|
|
logger.Get().SetVerbose(c.Bool("verbose"))
|
|
|
|
render.Render(
|
|
checker.CheckDomains(c.StringSlice("domain")),
|
|
30, 14,
|
|
NormalizeFormat(c.String("format")),
|
|
)
|
|
|
|
return nil
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|