(cmd *cobra.Command, args []string)
| 49 | } |
| 50 | |
| 51 | func debugTermRun(cmd *cobra.Command, args []string) (rtnErr error) { |
| 52 | defer func() { |
| 53 | sendActivity("debugterm", rtnErr == nil) |
| 54 | }() |
| 55 | mode, err := getDebugTermMode() |
| 56 | if err != nil { |
| 57 | return err |
| 58 | } |
| 59 | if debugTermStdin { |
| 60 | stdinData, err := io.ReadAll(WrappedStdin) |
| 61 | if err != nil { |
| 62 | return fmt.Errorf("reading stdin: %w", err) |
| 63 | } |
| 64 | termData, err := parseDebugTermStdinData(stdinData) |
| 65 | if err != nil { |
| 66 | return err |
| 67 | } |
| 68 | if mode == DebugTermModeDecode { |
| 69 | WriteStdout("%s", formatDebugTermDecode(termData)) |
| 70 | } else { |
| 71 | WriteStdout("%s", formatDebugTermHex(termData)) |
| 72 | } |
| 73 | return nil |
| 74 | } |
| 75 | if debugTermInput != "" { |
| 76 | fileData, err := os.ReadFile(debugTermInput) |
| 77 | if err != nil { |
| 78 | return fmt.Errorf("reading input file: %w", err) |
| 79 | } |
| 80 | termData, err := parseDebugTermStdinData(fileData) |
| 81 | if err != nil { |
| 82 | return err |
| 83 | } |
| 84 | if mode == DebugTermModeDecode { |
| 85 | WriteStdout("%s", formatDebugTermDecode(termData)) |
| 86 | } else { |
| 87 | WriteStdout("%s", formatDebugTermHex(termData)) |
| 88 | } |
| 89 | return nil |
| 90 | } |
| 91 | if debugTermSize <= 0 { |
| 92 | return fmt.Errorf("size must be greater than 0") |
| 93 | } |
| 94 | fullORef, err := resolveBlockArg() |
| 95 | if err != nil { |
| 96 | return err |
| 97 | } |
| 98 | rtn, err := wshclient.DebugTermCommand(RpcClient, wshrpc.CommandDebugTermData{ |
| 99 | BlockId: fullORef.OID, |
| 100 | Size: debugTermSize, |
| 101 | }, &wshrpc.RpcOpts{Timeout: 2000}) |
| 102 | if err != nil { |
| 103 | return fmt.Errorf("reading terminal output: %w", err) |
| 104 | } |
| 105 | termData, err := base64.StdEncoding.DecodeString(rtn.Data64) |
| 106 | if err != nil { |
| 107 | return fmt.Errorf("decoding terminal output: %w", err) |
| 108 | } |
nothing calls this directly
no test coverage detected