diff options
author | Alan Pearce | 2024-05-09 16:47:41 +0200 |
---|---|---|
committer | Alan Pearce | 2024-05-09 19:27:55 +0200 |
commit | e062ca72b222b890e345548bd8422d5df98e9fef (patch) | |
tree | 89f52ebfdb1fb8069e6323d9dde42f5491dad5d1 /process/main.go | |
parent | 967f6fdf5c1693d3aa27079b3ae28768fb7356c6 (diff) | |
download | searchix-e062ca72b222b890e345548bd8422d5df98e9fef.tar.lz searchix-e062ca72b222b890e345548bd8422d5df98e9fef.tar.zst searchix-e062ca72b222b890e345548bd8422d5df98e9fef.zip |
feat: import sources from configuration in go code and index options
Diffstat (limited to 'process/main.go')
-rw-r--r-- | process/main.go | 49 |
1 files changed, 0 insertions, 49 deletions
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) - } -} |