package main import ( "errors" "flag" "io/fs" "git.faercol.me/faercol/http-boot-config/config/logger" "git.faercol.me/faercol/http-boot-config/config/prober" ) type cliArgs struct { debug bool colour bool } func parseArgs() cliArgs { debugFlag := flag.Bool("debug", false, "Display debug logs") noColourFlag := flag.Bool("no-colour", false, "Disable colour logs") flag.Parse() return cliArgs{ debug: *debugFlag, colour: !*noColourFlag, } } func displayAppList(apps []prober.EfiApp, l *logger.SimpleLogger) { l.Info("Found the following EFI applications:") for _, a := range apps { prefix := " " if a.Active { prefix = "*" } l.Infof("\t- %s[%d] %s: %s", prefix, a.ID, a.Name, a.Path) } } func main() { args := parseArgs() l := logger.New(args.colour, args.debug) l.Info("Checking EFI directory for available boot images...") images, err := prober.GetEFIApps(l) if err != nil { if errors.Is(err, fs.ErrPermission) { l.Fatal("Permission error, try to run the command as sudo") } l.Fatalf("Failed to check EFI directory: %s", err.Error()) } displayAppList(images, l) }