X-Git-Url: http://git.giacomolli.uk/onechat/blobdiff_plain/0a98ccb67c3df55c0fe6d76b45afcbaa58c2eda1..459656ed8c15847d325f07758e4a775935411c3d:/main.go diff --git a/main.go b/main.go index f2c263d..04b0677 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,19 @@ import ( "syscall" ) +// usage is the help text of the command. +const usage = `Usage: onechat [COMMAND] + +Commands: + chat talk to the agent in this terminal (default) + daemon run the agent, Telegram, and WhatsApp + login log in to ChatGPT with a device code + probe LOG COUNT [BUILDS] measure the compactor on a log, with real calls + help show this help + +Chat needs a running daemon. ONECHAT_DIR sets the data directory. +` + func main() { err := run() if err != nil { @@ -23,8 +36,8 @@ func run() error { args := os.Args[1:] switch { - case len(args) == 0: - _, err := fmt.Println("onechat") + case len(args) == 1 && (args[0] == "help" || args[0] == "--help" || args[0] == "-h"): + _, err := fmt.Print(usage) if err != nil { return err } @@ -37,7 +50,7 @@ func run() error { // result does not include ctx.Err(). case len(args) == 1 && args[0] == "daemon": return daemon(ctx, os.Stdout) - case len(args) == 1 && args[0] == "chat": + case len(args) == 0 || len(args) == 1 && args[0] == "chat": return terminal(ctx, os.Stdin, os.Stdout) case len(args) > 0 && args[0] == "probe": err := probe(ctx, args[1:], os.Stdout) @@ -45,7 +58,7 @@ func run() error { return err } default: - return fmt.Errorf("unknown command %q", strings.Join(args, " ")) + return fmt.Errorf("unknown command %q\n\n%s", strings.Join(args, " "), strings.TrimSuffix(usage, "\n")) } return ctx.Err()