Skip to content

Commit a28285d

Browse files
justinabrahmsclaude
andcommitted
Add hidden dump command for vCard debugging
frm dump <name> prints the raw vCard for a contact. Hidden from help output, useful for debugging field storage issues. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d701061 commit a28285d

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

cmd_dump.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package main
2+
3+
import (
4+
"bytes"
5+
"fmt"
6+
7+
"github.com/emersion/go-vcard"
8+
"github.com/spf13/cobra"
9+
)
10+
11+
func init() {
12+
cmd := &cobra.Command{
13+
Use: "dump <name>",
14+
Short: "Dump raw vCard for a contact (debugging)",
15+
Args: cobra.ExactArgs(1),
16+
Hidden: true,
17+
RunE: func(cmd *cobra.Command, args []string) error {
18+
cfg, err := loadConfig()
19+
if err != nil {
20+
return err
21+
}
22+
23+
obj, _, err := findContactMulti(cfg, args[0])
24+
if err != nil {
25+
return err
26+
}
27+
28+
var buf bytes.Buffer
29+
enc := vcard.NewEncoder(&buf)
30+
if err := enc.Encode(obj.Card); err != nil {
31+
return fmt.Errorf("encoding vcard: %w", err)
32+
}
33+
fmt.Print(buf.String())
34+
return nil
35+
},
36+
}
37+
rootCmd.AddCommand(cmd)
38+
}

0 commit comments

Comments
 (0)