cmd

package
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version is the current release version of zentao-cli.
	// 由 goreleaser 通过 -X 注入;go install 构建时回退到 build info 中的模块版本。
	Version = "dev"
	// SDKVersion is the compatible ZenTao PMS SDK release version.
	SDKVersion = "zentaopms_21.7_20250516"
	// ZenTaoCompat is the target ZenTao PMS major/minor version compatibility.
	ZenTaoCompat = "21.7"
	// GitCommit is set at compile time.
	GitCommit = "HEAD"
	// BuildDate is set at compile time.
	BuildDate = "unknown"
)
View Source
var RootCmd = &cobra.Command{
	Use:   "zentao",
	Short: "禅道 (ZenTao PMS) 命令行工具(深度适配 AI Agent 与自动化脚本)",
	Long: `zentao-cli 是基于禅道官方 PHP SDK (v21.7+) 与原生 JSON 接口开发的现代化命令行工具。
提供个人工作台/待办看板(my/todo)、任务、缺陷、项目、产品等全方位能力,支持持久化会话凭据管理与确定性结构化输出。`,
	SilenceUsage:  true,
	SilenceErrors: true,
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {

		opts, err := config.Load(flagOpts)
		if err != nil {
			return err
		}
		runtimeOpts = opts
		printer = output.New(opts.Output)
		printer.Out = cmd.OutOrStdout()
		printer.Err = cmd.ErrOrStderr()

		zcfg := opts.ToZentaoConfig()
		client = zentao.New(zcfg)
		client.OnSessionRefreshed = func(cookie, rand string) {
			config.UpdateActiveProfileCookie(cookie, rand)
		}

		if profile, err := config.GetActiveProfile(""); err == nil && profile != nil {
			if client.BaseURL == "" {
				client.BaseURL = strings.TrimRight(profile.URL, "/")
			}
			if client.Account == "" {
				client.Account = profile.Account
			}
			if client.Password == "" && profile.Password != "" {
				client.Password = profile.Password
			}
			if client.GetRand() == "" {
				client.SetRand(profile.Rand)
			}
			if profile.Cookie != "" {
				client.Cookie = profile.Cookie
			}
		}

		return nil
	},
}

RootCmd represents the base command when called without any subcommands.

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately.

Types

type CommandSchema

type CommandSchema struct {
	Name        string          `json:"name"`
	Path        string          `json:"path"`
	Description string          `json:"description"`
	Effect      string          `json:"effect"` // read | write | destructive
	Risk        string          `json:"risk"`   // low | medium | high
	UseWhen     string          `json:"use_when,omitempty"`
	AvoidWhen   string          `json:"avoid_when,omitempty"`
	Parameters  []ParamSchema   `json:"parameters,omitempty"`
	Subcommands []CommandSchema `json:"subcommands,omitempty"`
	Examples    []string        `json:"examples,omitempty"`
}

CommandSchema represents a tool specification for LLM Agent discovery.

type ParamSchema

type ParamSchema struct {
	Name        string `json:"name"`
	Shorthand   string `json:"shorthand,omitempty"`
	Type        string `json:"type"`
	Required    bool   `json:"required"`
	Default     string `json:"default,omitempty"`
	Description string `json:"description"`
}

ParamSchema describes a CLI parameter flag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL