61 lines
1.0 KiB
Go

package main
import (
"context"
"fmt"
"os"
"github.com/urfave/cli/v3"
"gitea.stevedudenhoeffer.com/steve/go-extractor/cmd/browser/pkg/browser"
"gitea.stevedudenhoeffer.com/steve/go-extractor/sites/megamillions"
)
type MegaMillionsFlags []cli.Flag
var Flags = MegaMillionsFlags{}
func (f MegaMillionsFlags) ToConfig(_ *cli.Command) megamillions.Config {
c := megamillions.DefaultConfig
return c
}
func main() {
var flags []cli.Flag
flags = append(flags, browser.Flags...)
flags = append(flags, Flags...)
cli := &cli.Command{
Name: "megamillions",
Usage: "Get MegaMillions information",
Flags: flags,
Action: func(ctx context.Context, cli *cli.Command) error {
b, err := browser.FromCommand(ctx, cli)
if err != nil {
return err
}
draw, next, err := Flags.ToConfig(cli).GetCurrent(ctx, b)
if err != nil {
return err
}
fmt.Printf("Drawing: %+v\n", draw)
fmt.Printf("Next Drawing: %+v\n", next)
return nil
},
}
err := cli.Run(context.Background(), os.Args)
if err != nil {
panic(err)
}
}