]> git.giacomolli.uk - onechat/blobdiff - main.go
Explain daemon log levels and journal filtering
[onechat] / main.go
diff --git a/main.go b/main.go
index 9c1c8b92f7abf6c301ad4a64c849b623838a13e7..a73407f7c8457e973f0fb7731312a139acb7c3d2 100644 (file)
--- a/main.go
+++ b/main.go
@@ -20,11 +20,15 @@ Commands:
     -n                     print the plan without model calls
   login                    log in to ChatGPT with a device code
   probe LOG COUNT [BUILDS] measure the compactor on a log, with real calls
+  version                  show the build version
   help                     show this help
 
 Chat needs a running daemon. ONECHAT_DIR sets the data directory.
 `
 
+// version is set by the package build and stays dev for direct Go builds.
+var version = "dev"
+
 func main() {
        err := run()
        if err != nil {
@@ -44,6 +48,11 @@ func run() error {
                if err != nil {
                        return fmt.Errorf("write command help: %w", err)
                }
+       case len(args) == 1 && args[0] == "version":
+               _, err := fmt.Println(version)
+               if err != nil {
+                       return fmt.Errorf("write build version: %w", err)
+               }
        case len(args) == 1 && args[0] == "login":
                err := chatgptLogin(ctx, os.Stdout)
                if err != nil {