diff --git a/atproto/syntax/cmd/atp-syntax/main.go b/atproto/syntax/cmd/atp-syntax/main.go index d208b367a..e1410e910 100644 --- a/atproto/syntax/cmd/atp-syntax/main.go +++ b/atproto/syntax/cmd/atp-syntax/main.go @@ -22,6 +22,12 @@ func main() { ArgsUsage: "", Action: runParseTID, }, + &cli.Command{ + Name: "parse-did", + Usage: "parse a DID", + ArgsUsage: "", + Action: runParseDID, + }, } h := slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelDebug}) slog.SetDefault(slog.New(h)) @@ -43,3 +49,18 @@ func runParseTID(cctx *cli.Context) error { return nil } + +func runParseDID(cctx *cli.Context) error { + s := cctx.Args().First() + if s == "" { + return fmt.Errorf("need to provide identifier as an argument") + } + + did, err := syntax.ParseDID(s) + if err != nil { + return err + } + fmt.Printf("%s\n", did) + + return nil +}