(cmd *cobra.Command, args []string)
| 73 | } |
| 74 | |
| 75 | func getMetaRun(cmd *cobra.Command, args []string) (rtnErr error) { |
| 76 | defer func() { |
| 77 | sendActivity("getmeta", rtnErr == nil) |
| 78 | }() |
| 79 | fullORef, err := resolveBlockArg() |
| 80 | if err != nil { |
| 81 | return err |
| 82 | } |
| 83 | if getMetaVerbose { |
| 84 | fmt.Fprintf(os.Stderr, "resolved-id: %s\n", fullORef.String()) |
| 85 | } |
| 86 | resp, err := wshclient.GetMetaCommand(RpcClient, wshrpc.CommandGetMetaData{ORef: *fullORef}, &wshrpc.RpcOpts{Timeout: 2000}) |
| 87 | if err != nil { |
| 88 | return fmt.Errorf("getting metadata: %w", err) |
| 89 | } |
| 90 | |
| 91 | var output interface{} |
| 92 | if len(args) > 0 { |
| 93 | if len(args) == 1 && !strings.HasSuffix(args[0], ":*") { |
| 94 | // Single key case - output just the value |
| 95 | output = resp[args[0]] |
| 96 | } else { |
| 97 | // Multiple keys or pattern matching case - output object |
| 98 | output = filterMetaKeys(resp, args) |
| 99 | } |
| 100 | } else { |
| 101 | // No args case - output full metadata |
| 102 | output = resp |
| 103 | } |
| 104 | |
| 105 | // Handle raw string output |
| 106 | if getMetaRawOutput { |
| 107 | if str, ok := output.(string); ok { |
| 108 | WriteStdout("%s\n", str) |
| 109 | return |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | outBArr, err := json.MarshalIndent(output, "", " ") |
| 114 | if err != nil { |
| 115 | return fmt.Errorf("formatting metadata: %w", err) |
| 116 | } |
| 117 | outStr := string(outBArr) |
| 118 | WriteStdout("%s\n", outStr) |
| 119 | return nil |
| 120 | } |
nothing calls this directly
no test coverage detected