feat: 实现完整的本地配置管理与CLI重构
本次重构实现了标准化的本地配置系统,替换原有的硬编码环境变量读取逻辑: 1. 新增跨平台的原子化配置文件读写,支持Unix和Windows系统 2. 新增init命令用于安全初始化和更新本地凭据 3. 替换原有错误提示文案为更友好的中文提示 4. 更新文档说明新的配置流程和安全规范 5. 新增完整的配置相关测试用例 6. 添加必要的依赖包支持
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
dto "code.zhecent.com/open/shop-crm-agent/internal/api"
|
||||
crmClient "code.zhecent.com/open/shop-crm-agent/internal/client"
|
||||
runtimeConfig "code.zhecent.com/open/shop-crm-agent/internal/config"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
@@ -26,12 +27,16 @@ func New(version string) *cobra.Command {
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error { return cmd.Help() },
|
||||
}
|
||||
cmd.AddCommand(newCrmAgentCustomerListCmd(), newCrmAgentProjectCmd(), newCrmAgentQuotationCmd(), newCrmAgentCatalogCmd(), newCrmAgentEditCmd())
|
||||
cmd.AddCommand(newInitCmd(), newCrmAgentCustomerListCmd(), newCrmAgentProjectCmd(), newCrmAgentQuotationCmd(), newCrmAgentCatalogCmd(), newCrmAgentEditCmd())
|
||||
return cmd
|
||||
}
|
||||
|
||||
func newCrmAgentHTTPClient() (*crmClient.Client, error) {
|
||||
return crmClient.New(os.Getenv("LIGHTCORE_API_BASE_URL"), os.Getenv("LIGHTCORE_SHOP_CRM_AGENT_TOKEN"), nil)
|
||||
configuration, err := runtimeConfig.Load()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return crmClient.New(configuration.APIBaseURL, configuration.Token, nil)
|
||||
}
|
||||
|
||||
func writeCrmAgentProto(writer io.Writer, message proto.Message) error {
|
||||
|
||||
Reference in New Issue
Block a user