mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
refactor(services): leave CLI flag and command names to the app layer
Services report ErrRunScanExhausted, ErrMaxPages and plain conflicts, and the commands add the --branch/--max-pages/--force hints. Unknown label names use the shared NotFoundError, and the repository-scoped review and team search refusal moves into tea search's own usage check. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
10 files changed
+37
-18
No files matched your search
+5
-1
@@ -256,7 +256,7 @@ func (a *application) apiCommand() *cobra.Command {
|
||||
response.tty = a.deps.Streams.OutTTY
|
||||
response.color = response.tty && a.colorEnabled()
|
||||
}
|
||||
return (services.API{Client: target.client}).Visit(cmd.Context(), services.APIOptions{Endpoint: endpoint, Method: method, Body: body, Headers: headers, Paginate: paginate, MaxPages: maxPages}, func(r *http.Response) error {
|
||||
err = (services.API{Client: target.client}).Visit(cmd.Context(), services.APIOptions{Endpoint: endpoint, Method: method, Body: body, Headers: headers, Paginate: paginate, MaxPages: maxPages}, func(r *http.Response) error {
|
||||
if verbose {
|
||||
if err := writeRequestHead(cmd.ErrOrStderr(), r.Request); err != nil {
|
||||
return err
|
||||
@@ -273,6 +273,10 @@ func (a *application) apiCommand() *cobra.Command {
|
||||
}
|
||||
return response.write(destination, r)
|
||||
})
|
||||
if errors.Is(err, services.ErrMaxPages) {
|
||||
return errors.New("API pagination exceeded --max-pages")
|
||||
}
|
||||
return err
|
||||
})
|
||||
}}
|
||||
cmd.Flags().StringVarP(&method, "method", "X", "GET", "HTTP `method`")
|
||||
|
||||
Reference in new issue
Block a user