mirror-checker-ng/main.go

58 lines
1.4 KiB
Go

package main
import (
"log"
"os"
"github.com/Nathan13888/mirror-checker2/v2/config"
"github.com/Nathan13888/mirror-checker2/v2/web"
"github.com/urfave/cli/v2"
)
func main() {
// Start CLI
// TODO: documentation - https://cli.urfave.org/v2/examples/full-api-example/
app := &cli.App{
Name: "CSC Mirror Checker 2",
Usage: "sees if the mirror is up!",
Version: config.BuildVersion,
EnableBashCompletion: true,
// https://cli.urfave.org/v2/examples/combining-short-options/
// TODO: flags for config file (mirrors.json) and input
Commands: []*cli.Command{
{
Name: "server",
Aliases: []string{"s", "serve", "web"},
Usage: "starts web API",
Action: func(cCtx *cli.Context) error {
// TODO: flags for port, listen address
return web.StartServer()
},
},
{
Name: "check",
Aliases: []string{"c"},
Usage: "checks particular mirror",
Action: func(cCtx *cli.Context) error {
return nil
},
// TODO: auto complete available mirrors, https://cli.urfave.org/v2/examples/combining-short-options/
// BashComplete: func(cCtx *cli.Context) {
// // This will complete if no args are passed
// if cCtx.NArg() > 0 {
// return
// }
// for _, t := range config.Mirrors {
// fmt.Println(t)
// }
// },
},
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}