about summary refs log tree commit diff stats
path: root/process
diff options
context:
space:
mode:
authorAlan Pearce2024-05-06 17:30:43 +0200
committerAlan Pearce2024-05-07 14:01:30 +0200
commit8c1332020d25f74baa463bb1cec0e6783f565034 (patch)
treecd770b758b2538b79c5f0ddf7187b2cd61380f8d /process
parentc0fbf11f843af84e8891a708c4d217dd6c523473 (diff)
downloadsearchix-8c1332020d25f74baa463bb1cec0e6783f565034.tar.lz
searchix-8c1332020d25f74baa463bb1cec0e6783f565034.tar.zst
searchix-8c1332020d25f74baa463bb1cec0e6783f565034.zip
feat: link to exact commits in NixOS/nixpkgs
Diffstat (limited to 'process')
-rw-r--r--process/main.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/process/main.go b/process/main.go
index 3c9b67a..1089144 100644
--- a/process/main.go
+++ b/process/main.go
@@ -4,6 +4,8 @@ import (
 	"log"
 	"log/slog"
 	"os"
+	"strings"
+
 	"searchix/internal/options"
 
 	"github.com/ardanlabs/conf/v3"
@@ -11,8 +13,11 @@ import (
 )
 
 type Config struct {
-	Input  string `conf:"short:i,required,help:NixOS options file (json)"`
-	Output string `conf:"short:o,default:/dev/stdout"`
+	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() {
@@ -29,8 +34,15 @@ func main() {
 		}
 		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)
+	err = options.Process(config.Input, config.Output, config.Channel, config.Revision)
 	if err != nil {
 		log.Fatalf("Error processing file: %v", err)
 	}