mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
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>
30 lines
849 B
Go
30 lines
849 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package app
|
|
|
|
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://"))
|
|
}
|