refactor: 项目更名 WeKnora → Academy
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s
- 全量替换代码/配置/文档中的项目名(保留上游 GitHub 链接、weixin 文档域名、Docker Hub 镜像名) - 重命名 32 个含项目名的文件/目录;Go module 路径改为 academy(含 client/cli 子模块) - docreader proto 描述符采用等长替换,保持序列化字节布局有效 - Dockerfile.app 构建网络修复: browserskill 离线产物通道、PyPI/apt 国内镜像 - 运行验证: go build ✓ docker compose up ✓ 健康检查 ✓
This commit is contained in:
1 parent
9097ee699d
commit
9058149576
3136 files changed
+18018
-18004
No files matched your search
+16
-16
@@ -5,9 +5,9 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/config"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/config"
|
||||
"academy/cli/internal/iostreams"
|
||||
)
|
||||
|
||||
type AddOptions struct {
|
||||
@@ -31,12 +31,12 @@ type addResult struct {
|
||||
Current bool `json:"current"`
|
||||
}
|
||||
|
||||
// NewCmdAdd builds `weknora profile add`. Registers a *credentialless*
|
||||
// NewCmdAdd builds `academy profile add`. Registers a *credentialless*
|
||||
// connection target - host + optional user only. Credentials for the new
|
||||
// profile are attached separately by making it active and running
|
||||
// `weknora auth login`, separating "where" the CLI talks to (the host) and
|
||||
// `academy auth login`, separating "where" the CLI talks to (the host) and
|
||||
// "how" it authenticates (the credential). Pass --use to switch to the new
|
||||
// profile immediately, then run `weknora auth login`.
|
||||
// profile immediately, then run `academy auth login`.
|
||||
func NewCmdAdd(f *cmdutil.Factory) *cobra.Command {
|
||||
opts := &AddOptions{}
|
||||
cmd := &cobra.Command{
|
||||
@@ -44,14 +44,14 @@ func NewCmdAdd(f *cmdutil.Factory) *cobra.Command {
|
||||
Short: "Register a new profile (host without credentials)",
|
||||
Long: `Add a new profile entry to config.yaml. Stores host (and optionally
|
||||
user) but does NOT prompt for credentials. To attach credentials, make the
|
||||
profile active (` + "`weknora profile use <n>`" + `, or ` + "`profile add <n> --use`" + `) and run
|
||||
` + "`weknora auth login`" + `.
|
||||
profile active (` + "`academy profile use <n>`" + `, or ` + "`profile add <n> --use`" + `) and run
|
||||
` + "`academy auth login`" + `.
|
||||
|
||||
The first profile added is auto-selected as the current profile. Subsequent
|
||||
adds leave the current profile untouched unless --use is passed.`,
|
||||
Example: ` weknora profile add staging --host https://staging.example.com
|
||||
weknora profile add prod --host https://prod.example.com --user alice@example.com
|
||||
weknora profile add prod --host https://prod.example.com --use # switch to it now`,
|
||||
Example: ` academy profile add staging --host https://staging.example.com
|
||||
academy profile add prod --host https://prod.example.com --user alice@example.com
|
||||
academy profile add prod --host https://prod.example.com --use # switch to it now`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
fopts, err := cmdutil.CheckFormatFlag(c)
|
||||
@@ -78,7 +78,7 @@ adds leave the current profile untouched unless --use is passed.`,
|
||||
return &cmdutil.Error{
|
||||
Code: cmdutil.CodeResourceAlreadyExists,
|
||||
Message: fmt.Sprintf("profile %q already exists", name),
|
||||
Hint: fmt.Sprintf("use a different name, or run `weknora profile remove %s` first", name),
|
||||
Hint: fmt.Sprintf("use a different name, or run `academy profile remove %s` first", name),
|
||||
}
|
||||
}
|
||||
if handled, err := cmdutil.HandleDryRun(c, opts.DryRun, cmdutil.DryRunPlan{
|
||||
@@ -104,7 +104,7 @@ adds leave the current profile untouched unless --use is passed.`,
|
||||
RequiredFlags: []string{"<name> (positional)", "--host"},
|
||||
Output: "envelope.data has name, host, user, current",
|
||||
Examples: []string{
|
||||
"weknora profile add prod --host https://kb.example.com --use",
|
||||
"academy profile add prod --host https://kb.example.com --use",
|
||||
},
|
||||
})
|
||||
return cmd
|
||||
@@ -130,7 +130,7 @@ func runAdd(opts *AddOptions, fopts *cmdutil.FormatOptions, name string) error {
|
||||
return &cmdutil.Error{
|
||||
Code: cmdutil.CodeResourceAlreadyExists,
|
||||
Message: fmt.Sprintf("profile %q already exists", name),
|
||||
Hint: fmt.Sprintf("use a different name, or run `weknora profile remove %s` first", name),
|
||||
Hint: fmt.Sprintf("use a different name, or run `academy profile remove %s` first", name),
|
||||
}
|
||||
}
|
||||
return runAddWithConfig(opts, fopts, name, host, cfg)
|
||||
@@ -158,9 +158,9 @@ func runAddWithConfig(opts *AddOptions, fopts *cmdutil.FormatOptions, name, host
|
||||
return fopts.Emit(iostreams.IO.Out, addResult{Name: name, Host: host, User: opts.User, Current: current}, nil)
|
||||
}
|
||||
if current {
|
||||
fmt.Fprintf(iostreams.IO.Out, "✓ Added profile %s (now current). Run `weknora auth login` to attach credentials.\n", name)
|
||||
fmt.Fprintf(iostreams.IO.Out, "✓ Added profile %s (now current). Run `academy auth login` to attach credentials.\n", name)
|
||||
} else {
|
||||
fmt.Fprintf(iostreams.IO.Out, "✓ Added profile %s. Run `weknora profile use %s` then `weknora auth login` to attach credentials.\n", name, name)
|
||||
fmt.Fprintf(iostreams.IO.Out, "✓ Added profile %s. Run `academy profile use %s` then `academy auth login` to attach credentials.\n", name, name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/config"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/config"
|
||||
"academy/cli/internal/iostreams"
|
||||
)
|
||||
|
||||
func TestAdd_HappyPath(t *testing.T) {
|
||||
|
||||
@@ -14,12 +14,12 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/config"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
"github.com/Tencent/WeKnora/cli/internal/prompt"
|
||||
"github.com/Tencent/WeKnora/cli/internal/secrets"
|
||||
sdk "github.com/Tencent/WeKnora/client"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/config"
|
||||
"academy/cli/internal/iostreams"
|
||||
"academy/cli/internal/prompt"
|
||||
"academy/cli/internal/secrets"
|
||||
sdk "academy/client"
|
||||
)
|
||||
|
||||
// profileDryRunFactory builds a Factory whose Client closure panics if
|
||||
@@ -42,7 +42,7 @@ func profileDryRunFactory(t *testing.T) *cmdutil.Factory {
|
||||
// withRootHarnessProfile wraps a profile subcommand under a synthetic root
|
||||
// cmd that registers the global persistent flags.
|
||||
func withRootHarnessProfile(sub *cobra.Command, args ...string) *cobra.Command {
|
||||
root := &cobra.Command{Use: "weknora"}
|
||||
root := &cobra.Command{Use: "academy"}
|
||||
pf := root.PersistentFlags()
|
||||
pf.BoolP("yes", "y", false, "")
|
||||
pf.String("format", "", "")
|
||||
|
||||
+10
-10
@@ -7,11 +7,11 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/config"
|
||||
"github.com/Tencent/WeKnora/cli/internal/format"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
"github.com/Tencent/WeKnora/cli/internal/output"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/config"
|
||||
"academy/cli/internal/format"
|
||||
"academy/cli/internal/iostreams"
|
||||
"academy/cli/internal/output"
|
||||
)
|
||||
|
||||
type ListOptions struct{}
|
||||
@@ -29,18 +29,18 @@ type listEntry struct {
|
||||
Current bool `json:"current"`
|
||||
}
|
||||
|
||||
// NewCmdList builds `weknora profile list`. Per-host enumeration with an
|
||||
// NewCmdList builds `academy profile list`. Per-host enumeration with an
|
||||
// active marker. Reads only config.yaml - no network, no keyring touch.
|
||||
func NewCmdList(f *cmdutil.Factory) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List configured profiles",
|
||||
Long: `Show every profile registered in ~/.config/weknora/config.yaml. The
|
||||
Long: `Show every profile registered in ~/.config/academy/config.yaml. The
|
||||
active profile (used by subsequent commands when --profile is unset) is
|
||||
marked with a leading "*". No network requests are issued.
|
||||
|
||||
The credential mode (api-key vs password) is intentionally not shown here -
|
||||
run "weknora auth list" for that. "profile list" is the catalog of *where*
|
||||
run "academy auth list" for that. "profile list" is the catalog of *where*
|
||||
the CLI can talk to; "auth list" is the catalog of *how*.`,
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(c *cobra.Command, _ []string) error {
|
||||
@@ -55,7 +55,7 @@ the CLI can talk to; "auth list" is the catalog of *how*.`,
|
||||
cmdutil.AddFormatFlag(cmd, profileListFields...)
|
||||
cmdutil.SetAgentHelp(cmd, cmdutil.AgentHelp{
|
||||
UsedFor: "list configured connection profiles (name, host, which is active)",
|
||||
Examples: []string{"weknora profile list", "weknora profile list --jq '.data[].name'"},
|
||||
Examples: []string{"academy profile list", "academy profile list --jq '.data[].name'"},
|
||||
Output: "envelope.data is an array of {name, host, user, current}",
|
||||
})
|
||||
return cmd
|
||||
@@ -82,7 +82,7 @@ func runList(fopts *cmdutil.FormatOptions) error {
|
||||
return fopts.Emit(iostreams.IO.Out, entries, meta)
|
||||
}
|
||||
if len(entries) == 0 {
|
||||
fmt.Fprintln(iostreams.IO.Out, "No profiles configured. Run `weknora auth login` (or `weknora profile add`) to create one.")
|
||||
fmt.Fprintln(iostreams.IO.Out, "No profiles configured. Run `academy auth login` (or `academy profile add`) to create one.")
|
||||
return nil
|
||||
}
|
||||
tw := tabwriter.NewWriter(iostreams.IO.Out, 0, 0, 2, ' ', 0)
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/config"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/config"
|
||||
"academy/cli/internal/iostreams"
|
||||
)
|
||||
|
||||
func TestList_Empty(t *testing.T) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Package profilecmd holds the `weknora profile` command tree
|
||||
// Package profilecmd holds the `academy profile` command tree
|
||||
// (list / add / remove / use).
|
||||
//
|
||||
// Package name `profilecmd` (not `profile`) to keep the pattern consistent
|
||||
@@ -9,10 +9,10 @@ package profilecmd
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"academy/cli/internal/cmdutil"
|
||||
)
|
||||
|
||||
// NewCmd builds the `weknora profile` parent command.
|
||||
// NewCmd builds the `academy profile` parent command.
|
||||
func NewCmd(f *cmdutil.Factory) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "profile",
|
||||
|
||||
+14
-14
@@ -5,11 +5,11 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/config"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
"github.com/Tencent/WeKnora/cli/internal/prompt"
|
||||
"github.com/Tencent/WeKnora/cli/internal/secrets"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/config"
|
||||
"academy/cli/internal/iostreams"
|
||||
"academy/cli/internal/prompt"
|
||||
"academy/cli/internal/secrets"
|
||||
)
|
||||
|
||||
type RemoveOptions struct {
|
||||
@@ -30,7 +30,7 @@ type removeResult struct {
|
||||
WasCurrent bool `json:"was_current"`
|
||||
}
|
||||
|
||||
// NewCmdRemove builds `weknora profile remove`. Drops the entry from
|
||||
// NewCmdRemove builds `academy profile remove`. Drops the entry from
|
||||
// config.yaml and best-effort clears keyring references. Removing a
|
||||
// non-current profile is low-friction (no prompt). Removing the *current*
|
||||
// profile triggers the destructive-write confirmation protocol (exit 10),
|
||||
@@ -41,15 +41,15 @@ func NewCmdRemove(f *cmdutil.Factory) *cobra.Command {
|
||||
Use: "remove <name>",
|
||||
Short: "Remove a profile (drops entry, clears keyring refs)",
|
||||
Long: `Deletes the named profile from config.yaml and best-effort clears any
|
||||
keyring references it owned (matches ` + "`weknora auth logout`" + `).
|
||||
keyring references it owned (matches ` + "`academy auth logout`" + `).
|
||||
|
||||
Removing the current profile also clears CurrentProfile - subsequent commands
|
||||
will error until you select another with ` + "`weknora profile use <name>`" + ` or pick
|
||||
will error until you select another with ` + "`academy profile use <name>`" + ` or pick
|
||||
one up via the global ` + "`--profile`" + ` flag. Because that change is observable in
|
||||
every later command, removing the current profile requires explicit -y/--yes
|
||||
in scripted / --format json invocations (exit code 10; see cli/README.md).`,
|
||||
Example: ` weknora profile remove staging # remove non-current → no prompt
|
||||
weknora profile remove production -y # remove current → confirm`,
|
||||
Example: ` academy profile remove staging # remove non-current → no prompt
|
||||
academy profile remove production -y # remove current → confirm`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
fopts, err := cmdutil.CheckFormatFlag(c)
|
||||
@@ -92,8 +92,8 @@ in scripted / --format json invocations (exit code 10; see cli/README.md).`,
|
||||
RequiredFlags: []string{"<name> (positional)"},
|
||||
Output: "envelope.data is {name, removed:true, was_current}",
|
||||
Examples: []string{
|
||||
"weknora profile remove staging",
|
||||
"weknora profile remove production -y",
|
||||
"academy profile remove staging",
|
||||
"academy profile remove production -y",
|
||||
},
|
||||
Warnings: []string{
|
||||
"Requires explicit user approval (exit 10 / input.confirmation_required); never auto-add -y.",
|
||||
@@ -118,7 +118,7 @@ func runRemove(opts *RemoveOptions, fopts *cmdutil.FormatOptions, name string, s
|
||||
// Confirmation only fires for removing the current profile - non-current
|
||||
// remove uses the same low-friction policy as `auth logout`.
|
||||
if wasCurrent {
|
||||
if err := cmdutil.ConfirmDestructive(p, opts.Yes, jsonOut, "remove", "current profile", name, "profile.remove", []string{"weknora", "profile", "remove", name, "-y"}); err != nil {
|
||||
if err := cmdutil.ConfirmDestructive(p, opts.Yes, jsonOut, "remove", "current profile", name, "profile.remove", []string{"academy", "profile", "remove", name, "-y"}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,7 @@ func runRemove(opts *RemoveOptions, fopts *cmdutil.FormatOptions, name string, s
|
||||
return fopts.Emit(iostreams.IO.Out, result, nil)
|
||||
}
|
||||
if wasCurrent {
|
||||
fmt.Fprintf(iostreams.IO.Out, "✓ Removed profile %s (current profile cleared - run `weknora profile use <name>` to pick another)\n", name)
|
||||
fmt.Fprintf(iostreams.IO.Out, "✓ Removed profile %s (current profile cleared - run `academy profile use <name>` to pick another)\n", name)
|
||||
} else {
|
||||
fmt.Fprintf(iostreams.IO.Out, "✓ Removed profile %s\n", name)
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/config"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
"github.com/Tencent/WeKnora/cli/internal/secrets"
|
||||
"github.com/Tencent/WeKnora/cli/internal/testutil"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/config"
|
||||
"academy/cli/internal/iostreams"
|
||||
"academy/cli/internal/secrets"
|
||||
"academy/cli/internal/testutil"
|
||||
)
|
||||
|
||||
// seedStore returns a MemStore pre-loaded with sentinel values for every
|
||||
|
||||
+10
-10
@@ -5,16 +5,16 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/config"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/config"
|
||||
"academy/cli/internal/iostreams"
|
||||
)
|
||||
|
||||
// profileUseFields enumerates fields surfaced for `--format json` discovery on
|
||||
// `profile use`.
|
||||
var profileUseFields = []string{"current_profile", "previous_profile"}
|
||||
|
||||
// NewCmdUse builds the `weknora profile use <name>` command.
|
||||
// NewCmdUse builds the `academy profile use <name>` command.
|
||||
func NewCmdUse(f *cmdutil.Factory) *cobra.Command {
|
||||
var dryRun bool
|
||||
cmd := &cobra.Command{
|
||||
@@ -23,15 +23,15 @@ func NewCmdUse(f *cmdutil.Factory) *cobra.Command {
|
||||
Long: `Switches the default profile written in config.yaml. Names are case-sensitive.
|
||||
|
||||
The active profile is what every subsequent command uses for auth + host. The
|
||||
global --profile flag (e.g. weknora --profile staging kb list) overrides for
|
||||
global --profile flag (e.g. academy --profile staging kb list) overrides for
|
||||
one command without writing to disk.
|
||||
|
||||
AI agents: Do NOT switch the active profile unless the user explicitly asked
|
||||
you to. Profile selection is a user preference; one-shot overrides should use
|
||||
the global --profile flag instead, which writes nothing to disk.`,
|
||||
Example: ` weknora profile use staging # persist switch
|
||||
weknora --profile staging kb list # one-shot override (no disk write)
|
||||
weknora profile use staging --format json # {current_profile, previous_profile}`,
|
||||
Example: ` academy profile use staging # persist switch
|
||||
academy --profile staging kb list # one-shot override (no disk write)
|
||||
academy profile use staging --format json # {current_profile, previous_profile}`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
fopts, err := cmdutil.CheckFormatFlag(c)
|
||||
@@ -53,7 +53,7 @@ the global --profile flag instead, which writes nothing to disk.`,
|
||||
cmdutil.SetAgentHelp(cmd, cmdutil.AgentHelp{
|
||||
UsedFor: "switch the default profile for subsequent commands (persists to config)",
|
||||
RequiredFlags: []string{"<name> (positional)"},
|
||||
Examples: []string{"weknora profile use staging"},
|
||||
Examples: []string{"academy profile use staging"},
|
||||
Output: "envelope.data confirms the now-active profile",
|
||||
})
|
||||
return cmd
|
||||
@@ -94,7 +94,7 @@ func notFoundError(name string, cfg *config.Config) error {
|
||||
return &cmdutil.Error{
|
||||
Code: cmdutil.CodeLocalProfileNotFound,
|
||||
Message: fmt.Sprintf("profile not found: %s", name),
|
||||
Hint: "no profiles registered - run `weknora auth login` first",
|
||||
Hint: "no profiles registered - run `academy auth login` first",
|
||||
}
|
||||
}
|
||||
keys := profileKeys(cfg.Profiles)
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/config"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/config"
|
||||
"academy/cli/internal/iostreams"
|
||||
)
|
||||
|
||||
func TestUse_OK(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user