From e062ca72b222b890e345548bd8422d5df98e9fef Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 9 May 2024 16:47:41 +0200 Subject: feat: import sources from configuration in go code and index options --- process/main.go | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 process/main.go (limited to 'process') diff --git a/process/main.go b/process/main.go deleted file mode 100644 index 1089144..0000000 --- a/process/main.go +++ /dev/null @@ -1,49 +0,0 @@ -package main - -import ( - "log" - "log/slog" - "os" - "strings" - - "searchix/internal/options" - - "github.com/ardanlabs/conf/v3" - "github.com/pkg/errors" -) - -type Config struct { - Input string `conf:"short:i,required,help:NixOS options file (json)"` - Output string `conf:"short:o,default:/dev/stdout"` - Revision string `conf:"short:r,flag:revision,default:master"` - RevisionFile string `conf:"short:f,flag:revision-file"` - Channel string `conf:"short:c,flag:channel,default:nixpkgs"` -} - -func main() { - if os.Getenv("DEBUG") != "" { - slog.SetLogLoggerLevel(slog.LevelDebug) - } - log.SetFlags(0) - - config := Config{} - help, err := conf.Parse("", &config) - if err != nil { - if errors.Is(err, conf.ErrHelpWanted) { - log.Fatalln(help) - } - log.Fatalf("parsing command line: %v", err) - } - if config.RevisionFile != "" { - f, err := os.ReadFile(config.RevisionFile) - if err != nil { - log.Fatalf("Error reading revision file %s: %v", config.RevisionFile, err) - } - config.Revision = strings.TrimSpace(string(f)) - } - - err = options.Process(config.Input, config.Output, config.Channel, config.Revision) - if err != nil { - log.Fatalf("Error processing file: %v", err) - } -} -- cgit 1.4.1