Documentation
¶
Index ¶
- Variables
- func ConfigExportCmd() *gcli.Command
- func ConfigGetCmd() *gcli.Command
- func ConfigImportCmd() *gcli.Command
- func ConfigSetCmd() *gcli.Command
- func EnvListCmd() *gcli.Command
- func EnvSetCmd() *gcli.Command
- func EnvUnsetCmd() *gcli.Command
- func GetOpFlag() models.OpFlag
- func ListActivityCmd() *gcli.Command
- func ListAllCmd() *gcli.Command
- func ListEnvCmd() *gcli.Command
- func ListPathCmd() *gcli.Command
- func ListToolsCmd() *gcli.Command
- func NewShellCmd() *gcli.Command
- func NewUnuseCmd() *gcli.Command
- func NewUseCmd() *gcli.Command
- func PathAddCmd() *gcli.Command
- func PathListCmd() *gcli.Command
- func PathRemoveCmd() *gcli.Command
- func PathSearchCmd() *gcli.Command
- func ShellDirenvCmd() *gcli.Command
- func ShellHookInitCmd() *gcli.Command
- func ToolsIndexCmd() *gcli.Command
- func ToolsInstallCmd() *gcli.Command
- func ToolsListCmd() *gcli.Command
- func ToolsRegisterCmd() *gcli.Command
- func ToolsShowCmd() *gcli.Command
- func ToolsUninstallCmd() *gcli.Command
- func ToolsUpdateCmd() *gcli.Command
Constants ¶
This section is empty.
Variables ¶
var ( // GlobalFlag option value GlobalFlag bool SaveDirenv bool DebugMode bool )
var ConfigCmd = &gcli.Command{ Name: "config", Desc: "Manage xenv configuration", Aliases: []string{"cfg"}, Subs: []*gcli.Command{ ConfigSetCmd(), ConfigGetCmd(), ConfigExportCmd(), ConfigImportCmd(), }, Config: func(c *gcli.Command) { c.BoolOpt(&configOpts.edit, "edit", "e", false, "Edit the configuration file in the default editor") }, Func: func(c *gcli.Command, args []string) error { if err := config.Mgr.Init(); err != nil { return fmt.Errorf("failed to load configuration: %w", err) } cfg := config.Mgr.Config c.Infoln("Loading config file:", cfg.ConfigFile()) managedSdkKey := fmt.Sprintf("4. Managed SDKs(%d)", len(cfg.SDKs)) show.AList("【Current Xenv Configuration】:", map[string]any{ "1. Default Bin Dir": cfg.BinDir, "2. Tool Install Dir": cfg.InstallDir, "3. Shell Hooks Dir": cfg.ShellHooksDir, managedSdkKey: cfg.SDKNames(), }) return nil }, }
ConfigCmd the xenv config command
var EnvCmd = &gcli.Command{ Name: "env", Desc: "Manage environment variables", Subs: []*gcli.Command{ EnvSetCmd(), EnvUnsetCmd(), EnvListCmd(), }, Func: func(c *gcli.Command, args []string) error { return listEnvs() }, }
EnvCmd the xenv env command
var InitCmd = &gcli.Command{ Name: "init", Desc: "Initialize xenv configuration and environment", Func: func(c *gcli.Command, args []string) error { if err := config.Mgr.Init(); err != nil { return fmt.Errorf("failed to load configuration: %w", err) } cfgMgr := config.Mgr cfg := config.Mgr.Config configPath := cfg.ConfigFile() configDir := filepath.Dir(configPath) if err := util.EnsureDir(configDir); err != nil { return fmt.Errorf("failed to create config directory: %w", err) } if _, err := os.Stat(configPath); err == nil { if err := cfgMgr.LoadConfig(configPath); err != nil { fmt.Printf("Warning: failed to load existing config: %v\n", err) } } else { if err := cfgMgr.SaveConfig(configPath); err != nil { return fmt.Errorf("failed to save default config: %w", err) } fmt.Printf("Created default configuration at: %s\n", configPath) } if err := util.EnsureDir(cfgMgr.Config.BinDir); err != nil { return fmt.Errorf("failed to create bin directory: %w", err) } if err := util.EnsureDir(cfgMgr.Config.InstallDir); err != nil { return fmt.Errorf("failed to create install directory: %w", err) } if err := util.EnsureDir(cfgMgr.Config.ShellHooksDir); err != nil { return fmt.Errorf("failed to create shell scripts directory: %w", err) } fmt.Println("Xenv initialization completed successfully!") fmt.Printf("Configuration file: %s\n", configPath) fmt.Printf("Bin directory: %s\n", cfgMgr.Config.BinDir) fmt.Printf("Install directory: %s\n", cfgMgr.Config.InstallDir) fmt.Printf("Shell scripts directory: %s\n", cfgMgr.Config.ShellHooksDir) return nil }, }
InitCmd the xenv init command
var ListCmd = &gcli.Command{ Name: "list", Desc: "List installed tools, environment variables, or PATH entries", Aliases: []string{"ls"}, Subs: []*gcli.Command{ ListToolsCmd(), ListEnvCmd(), ListPathCmd(), ListActivityCmd(), ListAllCmd(), }, Func: func(c *gcli.Command, args []string) error { return listTools() }, }
ListCmd the xenv list command
var PathCmd = &gcli.Command{ Name: "path", Desc: "Manage PATH environment variable", Subs: []*gcli.Command{ PathAddCmd(), PathRemoveCmd(), PathListCmd(), PathSearchCmd(), }, Func: func(c *gcli.Command, args []string) error { return listEnvPaths() }, }
PathCmd the xenv path command
var ToolsCmd = &gcli.Command{ Name: "tools", Desc: "Manage local development SDK, tools (install, list, etc.)", Aliases: []string{"t", "tool"}, Subs: []*gcli.Command{ ToolsInstallCmd(), ToolsUninstallCmd(), ToolsUpdateCmd(), ToolsShowCmd(), ToolsListCmd(), ToolsRegisterCmd(), ToolsIndexCmd(), }, Config: func(c *gcli.Command) { }, }
ToolsCmd the xenv tools command
Functions ¶
func ConfigExportCmd ¶
ConfigExportCmd command for exporting configuration
func ConfigGetCmd ¶
ConfigGetCmd command for getting configuration values
func ConfigImportCmd ¶
ConfigImportCmd command for importing configuration
func ConfigSetCmd ¶
ConfigSetCmd command for setting configuration values
func EnvListCmd ¶
EnvListCmd command for listing environment variables
func EnvSetCmd ¶
EnvSetCmd command for setting environment variables
Test run:
// pwsh $env:XENV_HOOK_SHELL="pwsh"; kite xenv set TEST003 value003
func EnvUnsetCmd ¶
EnvUnsetCmd command for unsetting environment variables
func ListActivityCmd ¶
ListActivityCmd lists active tools and settings
func ListToolsCmd ¶
ListToolsCmd lists tools (similar to the one in tools subcommand)
func PathRemoveCmd ¶
PathRemoveCmd command for removing a path from PATH
func PathSearchCmd ¶
PathSearchCmd command for searching PATH entries
func ShellDirenvCmd ¶
ShellDirenvCmd the xenv init shell direnv command
- 仅在配置了 xenv shell 命令时,cd 到新目录会自动调用当前命令
- 监听进入目录时,自动检测 .xenv.toml 文件,并加载里面的配置
func ShellHookInitCmd ¶
ShellHookInitCmd the xenv hook init command
- 配置了 xenv shell 命令到 user 配置文件后,会自动执行该命令
- 调用当前命令,可以返回脚本内容自动执行
func ToolsIndexCmd ¶
ToolsIndexCmd command for 将本地的工具信息索引到 local.json
func ToolsInstallCmd ¶
ToolsInstallCmd command for installing tools
func ToolsRegisterCmd ¶
func ToolsUninstallCmd ¶
ToolsUninstallCmd command for uninstalling tools
Types ¶
This section is empty.