coderSubcommand extracts the @coder subcommand from the first arg, handling both the JSON envelope ({"cmd":"read","args":{…}}) and the positional form (`read --file foo`).
(args []string)
| 79 | // handling both the JSON envelope ({"cmd":"read","args":{…}}) and the |
| 80 | // positional form (`read --file foo`). |
| 81 | func coderSubcommand(args []string) string { |
| 82 | if len(args) == 0 { |
| 83 | return "" |
| 84 | } |
| 85 | first := strings.TrimSpace(args[0]) |
| 86 | if strings.HasPrefix(first, "{") { |
| 87 | if v := extractStringArg([]string{first}, "cmd", "command"); v != "" { |
| 88 | return v |
| 89 | } |
| 90 | } |
| 91 | return first |
| 92 | } |
no test coverage detected