]> git.giacomolli.uk - onechat/blobdiff - command.go
Complete context on forwarded local errors
[onechat] / command.go
index 02901e2a8f93a3df841e4fbc23101a38abd15420..fefb662da21039a37d44f0ccaca750abe2d6c0f7 100644 (file)
@@ -54,15 +54,40 @@ func parseCommand(ctx context.Context, args []string) error {
        // 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":
-               return daemon(ctx, os.Stdout)
+               err := daemon(ctx, os.Stdout)
+               if err != nil {
+                       return fmt.Errorf("run daemon: %w", err)
+               }
+
+               return nil
        case len(args) == 0 || len(args) == 1 && args[0] == "chat":
-               return terminal(ctx, os.Stdin, os.Stdout)
+               err := terminal(ctx, os.Stdin, os.Stdout)
+               if err != nil {
+                       return fmt.Errorf("run terminal: %w", err)
+               }
+
+               return nil
        case len(args) == 2 && args[0] == "backup":
-               return backup(ctx, args[1], os.Stdout)
+               err := backup(ctx, args[1], os.Stdout)
+               if err != nil {
+                       return fmt.Errorf("run backup: %w", err)
+               }
+
+               return nil
        case len(args) == 2 && args[0] == "restore":
-               return restore(ctx, args[1], os.Stdout)
+               err := restore(ctx, args[1], os.Stdout)
+               if err != nil {
+                       return fmt.Errorf("run restore: %w", err)
+               }
+
+               return nil
        case len(args) > 0 && args[0] == "import":
-               return whatsappImport(ctx, args[1:], os.Stdout)
+               err := whatsappImport(ctx, args[1:], os.Stdout)
+               if err != nil {
+                       return fmt.Errorf("import WhatsApp history: %w", err)
+               }
+
+               return nil
        case len(args) > 0 && args[0] == "probe":
                err := probe(ctx, args[1:], os.Stdout)
                if err != nil {