mirror of
https://github.com/larksuite/cli.git
synced 2026-07-08 02:00:19 +08:00
* feat(credential): add ActiveExtensionProviderName to detect external providers Change-Id: Ie17a4b714e5eca17ae574ac188d570721790107d * feat(cmdutil): add RequireBuiltinCredentialProvider guard for external credential providers Change-Id: I8f2ea0af6fe6506b29beb69264b04c21c0f75da1 * feat(config): block all config subcommands when external credential provider is active Change-Id: If215cb8f0a53cc92d623dd3d842e4465124af2be * feat(auth): block all auth subcommands when external credential provider is active Change-Id: Ia61184fb2daeb6a7a38d122c647b7cb67eaf8b1f * fix(auth,config): silence usage in PersistentPreRunE to match root command behaviour Change-Id: I6d4b3c7d9d9c7b10fc2482fdc80252bf051771ee * test(auth,config,credential): address CodeRabbit review comments - Use cmd.Find() to assert SilenceUsage on matched subcommand (not parent) - Add TestRequireBuiltinCredentialProvider_PropagatesProviderError for error path - Add 'external' fallback sentinel in ActiveExtensionProviderName Change-Id: Iba35779ad2ed9807556264ba23db7096541e2bf3
40 lines
1.3 KiB
Go
40 lines
1.3 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package config
|
|
|
|
import (
|
|
"github.com/larksuite/cli/internal/cmdutil"
|
|
"github.com/larksuite/cli/internal/core"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// NewCmdConfig creates the config command with subcommands.
|
|
func NewCmdConfig(f *cmdutil.Factory) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "config",
|
|
Short: "Global CLI configuration management",
|
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
|
// Replicate rootCmd's PersistentPreRun behaviour: cobra stops at the first
|
|
// PersistentPreRun[E] found walking up the chain, so the root-level
|
|
// SilenceUsage=true would be skipped without this line.
|
|
cmd.SilenceUsage = true
|
|
// Pass "config" as a literal — cmd.Name() would return the subcommand name.
|
|
return f.RequireBuiltinCredentialProvider(cmd.Context(), "config")
|
|
},
|
|
}
|
|
cmdutil.DisableAuthCheck(cmd)
|
|
|
|
cmd.AddCommand(NewCmdConfigInit(f, nil))
|
|
cmd.AddCommand(NewCmdConfigBind(f, nil))
|
|
cmd.AddCommand(NewCmdConfigRemove(f, nil))
|
|
cmd.AddCommand(NewCmdConfigShow(f, nil))
|
|
cmd.AddCommand(NewCmdConfigDefaultAs(f))
|
|
cmd.AddCommand(NewCmdConfigStrictMode(f))
|
|
return cmd
|
|
}
|
|
|
|
func parseBrand(value string) core.LarkBrand {
|
|
return core.ParseBrand(value)
|
|
}
|