]> git.giacomolli.uk - onechat/blobdiff - main.go
Share the Markdown marks and block parser
[onechat] / main.go
diff --git a/main.go b/main.go
index f4f09c47ba7f78919630a61b11b1899216715d31..a73407f7c8457e973f0fb7731312a139acb7c3d2 100644 (file)
--- a/main.go
+++ b/main.go
@@ -1,3 +1,4 @@
+// Command onechat runs the agent daemon and its terminal client.
 package main
 
 import (
 package main
 
 import (
@@ -19,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
     -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.
 `
 
   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 {
 func main() {
        err := run()
        if err != nil {
@@ -41,13 +46,19 @@ func run() error {
        case len(args) == 1 && (args[0] == "help" || args[0] == "--help" || args[0] == "-h"):
                _, err := fmt.Print(usage)
                if err != nil {
        case len(args) == 1 && (args[0] == "help" || args[0] == "--help" || args[0] == "-h"):
                _, err := fmt.Print(usage)
                if err != nil {
-                       return err
+                       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 {
                        return err
                }
                }
        case len(args) == 1 && args[0] == "login":
                err := chatgptLogin(ctx, os.Stdout)
                if err != nil {
                        return err
                }
+
        // A signal is the normal stop of the daemon and the client, so their
        // result does not include ctx.Err().
        case len(args) == 1 && args[0] == "daemon":
        // A signal is the normal stop of the daemon and the client, so their
        // result does not include ctx.Err().
        case len(args) == 1 && args[0] == "daemon":