feat(app): report mutations on stderr and say what --web opens

Mutations printed a list row, or nothing, so a person could not tell
what changed and scripts parsed rows meant for people. Commands now get
the helpers for the gh convention:

- done and warn print "✓ Closed issue alice/x#5 (Fix login)" and
  "! … is already closed" to stderr, only when stdout is a terminal and
  --json is not set.
- printURL prints a created resource's URL to stdout unless --json is
  set, so url=$(tea issue create …) works.
- batchDone applies a mutation to several selections like batch and
  reports each success with a done line instead of a table.
- issueRef formats "alice/x#5 (title)" references.

--web now prints "Opening localhost:3001/alice/project/issues/1 in your
browser." to stderr on a terminal before the browser starts.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-11 22:43:11 +02:00
1 parent 55574a9fd0
commit 4fddcc6781
4 files changed
+167 -12

No files matched your search

+16 -1
View File
@@ -3,12 +3,27 @@
package app
import "github.com/spf13/cobra"
import (
"fmt"
"strings"
"gitea.dev/tea/internal/terminal"
"github.com/spf13/cobra"
)
// openBrowser opens resource in the configured browser, telling people on a terminal what opens.
func (a *application) openBrowser(command *cobra.Command, resource string) error {
preferences, err := a.preferences()
if err != nil {
return err
}
if a.deps.Streams.OutTTY {
fmt.Fprintf(command.ErrOrStderr(), "Opening %s in your browser.\n", displayURL(resource))
}
return a.deps.Browser.Open(command.Context(), resource, preferences.Browser)
}
// displayURL shows a URL to people without its scheme, like gh.
func displayURL(url string) string {
return terminal.SafeLine(strings.TrimPrefix(strings.TrimPrefix(url, "https://"), "http://"))
}