QueryEditorInput will open the default editor in the terminal with a template for the user to fill. The file is then processed to extract a query.
(repo repository.RepoCommonStorage, preQuery string)
| 206 | // QueryEditorInput will open the default editor in the terminal with a |
| 207 | // template for the user to fill. The file is then processed to extract a query. |
| 208 | func QueryEditorInput(repo repository.RepoCommonStorage, preQuery string) (string, error) { |
| 209 | template := fmt.Sprintf(queryTemplate, preQuery) |
| 210 | |
| 211 | raw, err := input.LaunchEditorWithTemplate(repo, messageFilename, template) |
| 212 | if err != nil { |
| 213 | return "", err |
| 214 | } |
| 215 | |
| 216 | lines := strings.Split(raw, "\n") |
| 217 | |
| 218 | for _, line := range lines { |
| 219 | if strings.HasPrefix(line, "#") { |
| 220 | continue |
| 221 | } |
| 222 | trimmed := strings.TrimSpace(line) |
| 223 | if trimmed == "" { |
| 224 | continue |
| 225 | } |
| 226 | return trimmed, nil |
| 227 | } |
| 228 | |
| 229 | return "", nil |
| 230 | } |
nothing calls this directly
no test coverage detected