mirror of
https://github.com/ehang-io/nps.git
synced 2025-07-03 21:20:41 +00:00
change something
This commit is contained in:
parent
b6a9001d43
commit
80f23836eb
@ -1,27 +1,34 @@
|
|||||||
|
// Copyright 2014 nps Author. All Rights Reserved.
|
||||||
package core
|
package core
|
||||||
|
|
||||||
// This structure is used to describe the plugin configuration item name and description.
|
import "regexp"
|
||||||
|
|
||||||
|
// this structure is used to describe the plugin configuration item name and description.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
ConfigName string
|
ConfigName string // single configuration item name
|
||||||
Description string
|
ZhTitle string // single configuration item chinese title
|
||||||
ConfigLevel ConfigLevel
|
EnTitle string // single configuration item english title
|
||||||
|
ZhDescription string // single configuration item chinese description
|
||||||
|
EnDescription string // single configuration item english description
|
||||||
|
LimitReg *regexp.Regexp // regular expression to restrict input
|
||||||
|
ConfigLevel ConfigLevel // configuration sector
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// multiple configuration collections for plugins
|
||||||
type NpsConfigs struct {
|
type NpsConfigs struct {
|
||||||
configs []*Config
|
ZhTitle string // chinese title for configuration collection
|
||||||
|
EnTitle string // chinese description of the configuration collection
|
||||||
|
EnDescription string // english description of the configuration collection
|
||||||
|
ZhDescription string // chinese description for english collection
|
||||||
|
configs []*Config // all configurations
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNpsConfigs(name, des string, level ConfigLevel) *NpsConfigs {
|
// insert one config into configs
|
||||||
c := &NpsConfigs{}
|
func (config *NpsConfigs) Add(cfg *Config) {
|
||||||
c.configs = make([]*Config, 0)
|
config.configs = append(config.configs, cfg)
|
||||||
c.Add(name, des, level)
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
func (config *NpsConfigs) Add(name, des string, level ConfigLevel) {
|
|
||||||
config.configs = append(config.configs, &Config{ConfigName: name, Description: des, ConfigLevel: level})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get all configs
|
||||||
func (config *NpsConfigs) GetAll() []*Config {
|
func (config *NpsConfigs) GetAll() []*Config {
|
||||||
return config.configs
|
return config.configs
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,17 @@ const (
|
|||||||
type ConfigLevel uint8
|
type ConfigLevel uint8
|
||||||
|
|
||||||
const (
|
const (
|
||||||
CONFIG_LEVEL_CLIENT ConfigLevel = iota
|
CONFIG_LEVEL_CLIENT ConfigLevel = iota // client-level configuration
|
||||||
CONFIG_LEVEL_PLUGIN
|
CONFIG_LEVEL_PLUGIN // plugin level control
|
||||||
CONFIG_LEVEL_GLOBAL
|
CONFIG_LEVEL_GLOBAL // global configuration
|
||||||
|
)
|
||||||
|
|
||||||
|
type ConfigInputType uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
CONFIG_INPUT_TEXT ConfigInputType = iota // show as single line input box
|
||||||
|
CONFIG_INPUT_SWITCH // show as switch
|
||||||
|
CONFIG_INPUT_TEXTAREA // show as a multi-line input box
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user