kiteext

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const BinPrefix = "kite-"

BinPrefix kite ext 命令文件名称前缀 eg: kite-abc -> ext: abc

Variables

This section is empty.

Functions

This section is empty.

Types

type ExtManager

type ExtManager struct {
	Disable bool `json:"disable"`
	// Metafile kite ext 注册记录文件 default: $config/module/ext.json
	Metafile string `json:"metafile"`
	// SearchPaths 除了 env PATH 外,额外搜索ext文件的目录
	SearchPaths []string `json:"search_paths"`
	// PathResolver handler. 用于查找 Metafile 文件
	PathResolver func(path string) string
	// contains filtered or unexported fields
}

ExtManager kite cli 扩展管理器实现 TODO 重构:将外部工具独立出去 external, 这里只管理 kite extension

func NewExtManager

func NewExtManager() *ExtManager

func (*ExtManager) Add

func (m *ExtManager) Add(ext *KiteExt) error

Add 添加一个扩展

func (*ExtManager) CleanInvalid

func (m *ExtManager) CleanInvalid() error

CleanInvalid 删除无效的(不存在的)扩展

func (*ExtManager) Delete

func (m *ExtManager) Delete(name string) error

Delete 删除扩展信息

func (*ExtManager) Dumpfile

func (m *ExtManager) Dumpfile() error

Dumpfile 保存扩展元数据

func (*ExtManager) Each

func (m *ExtManager) Each(fn func(ext *KiteExt))

Each every ext information

func (*ExtManager) Exists

func (m *ExtManager) Exists(name string) bool

Exists checks ext exists.

func (*ExtManager) Ext

func (m *ExtManager) Ext(name string) (ext *KiteExt, ok bool)

Ext gets ext by name

func (*ExtManager) Exts

func (m *ExtManager) Exts() []*KiteExt

Exts gets ext list.

func (*ExtManager) Init

func (m *ExtManager) Init() error

Init 初始化ext manager

func (*ExtManager) QuickAdd

func (m *ExtManager) QuickAdd(name, desc string, path ...string) error

QuickAdd 添加一个扩展

func (*ExtManager) Run

func (m *ExtManager) Run(name string, ctx *RunCtx) error

Run 运行ext命令

func (*ExtManager) Update

func (m *ExtManager) Update(ext *KiteExt) error

Update 更新扩展信息

type KiteExt

type KiteExt struct {

	// 扩展名称
	Name string `json:"name"`
	Desc string `json:"desc"`
	// 别名列表
	Aliases []string `json:"aliases,omitempty"`
	// OsPaths 不同系统平台下的文件路径
	//  - key: 系统平台 windows, darwin, linux. value: 扩展文件路径
	OsPaths map[string]string `json:"os_paths"`

	// Args 默认运行参数
	Args []string `json:"args,omitempty"`
	// 指定默认运行目录
	Workdir  string `json:"workdir,omitempty"`
	Disable  bool   `json:"disable,omitempty"`
	Author   string `json:"author,omitempty"`
	Version  string `json:"version,omitempty"`
	Homepage string `json:"homepage,omitempty"`

	// BeforeSave 保存前执行 hook.
	//  - 返回 true 继续保存,返回 false 停止保存
	BeforeSave func(ext *KiteExt) bool `json:"-"`
	// contains filtered or unexported fields
}

KiteExt kite ext 基本信息

func NewExt

func NewExt(name, desc string, path ...string) *KiteExt

func (*KiteExt) BinName

func (e *KiteExt) BinName() string

BinName get the bin name, without an ext name.

func (*KiteExt) IsValid

func (e *KiteExt) IsValid() bool

IsValid check path is valid

func (*KiteExt) OsPath

func (e *KiteExt) OsPath() string

OsPath in the current os

func (*KiteExt) SetAliases

func (e *KiteExt) SetAliases(str string)

SetAliases set aliases for the extension.

func (*KiteExt) SetBinName

func (e *KiteExt) SetBinName(name string)

SetBinName set bin name

func (*KiteExt) SetPath

func (e *KiteExt) SetPath(osPath string)

SetPath set file path in the current os

type MetaSchema

type MetaSchema struct {
	Uptime string     `json:"uptime"`
	Exts   []*KiteExt `json:"exts"`
}

MetaSchema kite ext 注册信息文件内容结构

type PathMap

type PathMap struct {

	// path alias map: {alias: path}
	maputil.Aliases `json:"path_map"`
	// if true, must start with prefix on resolve path.
	Strict bool `json:"strict"`
	// allowed prefix mark for alias, use on resolve. eg: "$,#,@"
	Prefixes string `json:"prefixes"`
	// FallbackFn if alias not exists, will call this func to get a path.
	FallbackFn func(path string) string
	// contains filtered or unexported fields
}

PathMap struct

func NewPathMap

func NewPathMap(opFns ...func(pm *PathMap)) *PathMap

NewPathMap instance

func (*PathMap) Data

func (p *PathMap) Data() map[string]string

Data get all alias map data

func (*PathMap) Resolve

func (p *PathMap) Resolve(path string) string

Resolve a path. eg: $home/some.txt => /home/USER/some.txt

type PluginRunner

type PluginRunner struct {
	// DenyNames deny plugin bin names
	DenyNames []string `json:"deny_names"`
	// PluginDirs plugin bin search dirs
	PluginDirs []string `json:"plugin_dirs"`
	ConfigFile []string `json:"config_file"`
}

PluginRunner struct

type RunCtx

type RunCtx struct {
	Dry bool
	// Dir 设置运行目录
	Dir string
	// Env 设置环境变量
	Env map[string]string
	// Args 运行参数
	Args []string
}

RunCtx data

type VarMap

type VarMap struct {
	Prefix string
	// contains filtered or unexported fields
}

VarMap struct

func NewVarMap

func NewVarMap(smp map[string]string) *VarMap

NewVarMap instance

func (*VarMap) Add

func (m *VarMap) Add(name, value string)

Add new var value

func (*VarMap) AliasMap

func (m *VarMap) AliasMap() map[string]string

AliasMap data get. key is prefix + alias

func (*VarMap) Data

func (m *VarMap) Data() map[string]string

Data raw map get. key is without prefix

func (*VarMap) LoadMap

func (m *VarMap) LoadMap(smp map[string]string)

LoadMap path

func (*VarMap) Replace

func (m *VarMap) Replace(s string) string

Replace vars in string.

func (*VarMap) Resolve

func (m *VarMap) Resolve(path string) string

Resolve a string value.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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