mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
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:
4 files changed
+167
-12
No files matched your search
+16
-1
@@ -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://"))
|
||||
}
|
||||
Reference in new issue
Block a user