59 lines
1.0 KiB
Go
Raw Permalink Normal View History

2024-12-24 12:15:48 -05:00
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/useragents"
)
type UseragentsFlags []cli.Flag
var Flags = UseragentsFlags{}
func (f UseragentsFlags) ToConfig(_ *cli.Command) useragents.Config {
c := useragents.DefaultConfig
return c
}
func main() {
var flags []cli.Flag
flags = append(flags, browser.Flags...)
flags = append(flags, Flags...)
cli := &cli.Command{
Name: "useragents",
Usage: "Get useragents.me information",
Flags: flags,
Action: func(ctx context.Context, cli *cli.Command) error {
b, err := browser.FromCommand(ctx, cli)
if err != nil {
return err
}
mostCommon, err := Flags.ToConfig(cli).GetMostCommonDesktopUserAgent(ctx, b)
if err != nil {
return err
}
fmt.Printf("Most Common User Agent: %+v\n", mostCommon)
return nil
},
}
err := cli.Run(context.Background(), os.Args)
if err != nil {
panic(err)
}
}