mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
fix(config): print only the value of config get and add display preferences
tea config get printed "key<TAB>value", so $(tea config get editor) was not usable; it now prints the value alone, and --show-source appends the source (D18). config get reads the instance's user, and instance settings come from the selected instance (--host, TEA_HOST, default_host or the sole instance). Unknown keys list the valid ones, and keys that need --host or --user say so. config path no longer loads the settings, so it works when hosts.yml is broken. config list is a table on a terminal. config set confirms the change on a terminal and warns when default_host has no account. config.yml stores the hyperlinks (auto, always, never) and markdown (auto, raw) preferences that tables and views now read, instead of the TEA_HYPERLINKS and TEA_MARKDOWN variables. The environment table moves out of tea config --help into tea help environment. alias set refuses to replace an alias without --clobber, drops a leading "tea", and explains how to quote an expansion with spaces or flags. alias delete takes several names or --all, alias list is a table, and an empty list says so on a terminal. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
9 files changed
+687
-271
No files matched your search
@@ -15,6 +15,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitea.dev/tea/internal/settings"
|
||||
"gitea.dev/tea/internal/terminal"
|
||||
"github.com/mattn/go-runewidth"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -51,6 +52,7 @@ func pagedDeps(t *testing.T, serverURL string, env map[string]string, config ...
|
||||
for i := 0; i < len(config); i += 2 {
|
||||
require.NoError(t, Execute(context.Background(), deps, []string{"config", "set", config[i], config[i+1]}))
|
||||
}
|
||||
diagnostics.Reset()
|
||||
return deps, out, diagnostics, pager
|
||||
}
|
||||
|
||||
@@ -174,7 +176,7 @@ func TestMultiItemHumanOutputPagesOnce(t *testing.T) {
|
||||
{[]string{"issue", "comment", "list", "5"}, "1 alice\none\n\n2 bob\ntwo\n\n"},
|
||||
} {
|
||||
t.Run(tc.args[0]+" "+tc.args[1], func(t *testing.T) {
|
||||
deps, out, _, pager := pagedDeps(t, server.URL, map[string]string{"TEA_HYPERLINKS": "never"}, "pager", "fake-pager", "color", "never")
|
||||
deps, out, _, pager := pagedDeps(t, server.URL, nil, "pager", "fake-pager", "color", "never", "hyperlinks", "never")
|
||||
require.NoError(t, Execute(context.Background(), deps, append(tc.args, "-R", "alice/project", "--yes")))
|
||||
require.Equal(t, 1, pager.calls)
|
||||
require.Equal(t, tc.want, pager.input)
|
||||
@@ -341,7 +343,11 @@ func TestWriteView(t *testing.T) {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
deps, out, _ := testDeps(t)
|
||||
deps.Streams.OutTTY = tc.tty
|
||||
deps.Getenv = envFunc(map[string]string{"NO_COLOR": "1", "TEA_MARKDOWN": "raw", "TEA_HYPERLINKS": "never"})
|
||||
deps.Getenv = envFunc(map[string]string{"NO_COLOR": "1"})
|
||||
require.NoError(t, deps.Settings.Update(settings.TargetPreferences, func(s *settings.Snapshot) error {
|
||||
s.Preferences.Markdown, s.Preferences.Hyperlinks = "raw", "never"
|
||||
return nil
|
||||
}))
|
||||
a, cmd := outputApplication(deps, tc.json)
|
||||
require.NoError(t, writeView(a, cmd, item, view))
|
||||
require.Equal(t, tc.want, out.String())
|
||||
|
||||
Reference in new issue
Block a user