Documentation
¶
Index ¶
- Constants
- Variables
- func InitConfig(rootCmd *cobra.Command) error
- func MarshalDebugJSONForCommand(cfg Config, cmd *cobra.Command) ([]byte, error)
- func ResetConfig()
- func SetConfig(command string, flagSet *pflag.FlagSet) error
- func TraverseCommands(prefix string, cmd *cobra.Command) error
- type AddApiConfig
- type AddConfig
- type AddProtoConfig
- type AddSqlConfig
- type AddSqlMigrationConfig
- type Config
- type FormatConfig
- type GenConfig
- type GenSwaggerConfig
- type HooksConfig
- type MigrateConfig
- type NewConfig
- type TemplateBuildConfig
- type TemplateConfig
- type TemplateInitConfig
- type ToolVersion
- type UpgradeConfig
Constants ¶
View Source
const DefaultStyle = "go_zero"
Variables ¶
View Source
var ( CfgFile string CfgEnvFile string )
Functions ¶
func InitConfig ¶
func MarshalDebugJSONForCommand ¶
MarshalDebugJSONForCommand marshals the effective config for the active command path.
func ResetConfig ¶
func ResetConfig()
Types ¶
type AddApiConfig ¶
type AddApiConfig struct{}
type AddConfig ¶
type AddConfig struct {
Output string `mapstructure:"output"`
Api AddApiConfig `mapstructure:"api"`
Proto AddProtoConfig `mapstructure:"proto"`
Sql AddSqlConfig `mapstructure:"sql"`
SqlMigration AddSqlMigrationConfig `mapstructure:"sql-migration"`
}
type AddProtoConfig ¶
type AddProtoConfig struct{}
type AddSqlConfig ¶
type AddSqlConfig struct{}
type AddSqlMigrationConfig ¶
type AddSqlMigrationConfig struct{}
type Config ¶
type Config struct {
// config file only
Hooks HooksConfig `mapstructure:"hooks"`
// root persistent flags
Debug bool `mapstructure:"debug"`
Quiet bool `mapstructure:"quiet"`
DebugSleepTime int `mapstructure:"debug-sleep-time"`
RegisterTplVal []string `mapstructure:"register-tpl-val"`
Home string `mapstructure:"home"`
Style string `mapstructure:"style"`
// new command
New NewConfig `mapstructure:"new"`
// add command
Add AddConfig `mapstructure:"add"`
// gen command
Gen GenConfig `mapstructure:"gen"`
// template command
Template TemplateConfig `mapstructure:"template"`
// upgrade command
Upgrade UpgradeConfig `mapstructure:"upgrade"`
// migrate command
Migrate MigrateConfig `mapstructure:"migrate"`
// format command
Format FormatConfig `mapstructure:"format"`
}
var C Config
C global command flags
func (*Config) ToolVersion ¶
func (c *Config) ToolVersion() ToolVersion
type FormatConfig ¶
type GenConfig ¶
type GenConfig struct {
Hooks HooksConfig `mapstructure:"hooks"`
Desc []string `mapstructure:"desc"`
DescIgnore []string `mapstructure:"desc-ignore"`
GitChange bool `mapstructure:"git-change"`
ApiTypesDir string `mapstructure:"api-types-dir"`
Route2Code bool
ProtoDirs []string `mapstructure:"proto-dir"` // RPC proto 扫描根,空则回落 desc/proto
ProtoInclude []string `mapstructure:"proto-include"`
RpcClient bool `mapstructure:"rpc-client"`
ModelDriver string `mapstructure:"model-driver"`
ModelStrict bool `mapstructure:"model-strict"`
ModelIgnoreColumns []string `mapstructure:"model-ignore-columns"`
ModelIgnoreColumnsTable []struct {
Table string `mapstructure:"table"`
Columns []string `mapstructure:"columns"`
} `mapstructure:"model-ignore-columns-table"`
ModelSchema string `mapstructure:"model-schema"`
ModelDatasource bool `mapstructure:"model-datasource"`
ModelDatasourceUrl []string `mapstructure:"model-datasource-url"`
ModelDatasourceTable []string `mapstructure:"model-datasource-table"`
ModelCache bool `mapstructure:"model-cache"`
ModelCacheTable []string `mapstructure:"model-cache-table"`
ModelCachePrefix string `mapstructure:"model-cache-prefix"`
ModelCacheExpiryTable []struct {
Table string `mapstructure:"table"`
Expiry int64 `mapstructure:"expiry"`
NotFoundExpiry int64 `mapstructure:"not-found-expiry"`
} `mapstructure:"model-cache-expiry-table"`
// Gen Sub Command
Swagger GenSwaggerConfig `mapstructure:"swagger"`
}
type GenSwaggerConfig ¶
type HooksConfig ¶
type MigrateConfig ¶
type NewConfig ¶
type NewConfig struct {
Name string `mapstructure:"name"` // 新建项目名称
Module string `mapstructure:"module"` // 新建的项目的 go module
Mono bool `mapstructure:"mono"` // 是否是 mono 项目(即在一个mod项目之下, 但该项目本身无 go.mod 文件)
Output string `mapstructure:"output"` // 输出到的目录
Remote string `mapstructure:"remote"` // 远程仓库地址
RemoteTimeout int `mapstructure:"remote-timeout"` // 远程仓库超时时间, 单位秒
Cache bool `mapstructure:"cache"` // 当使用远程仓库时是否使用缓存
Gen bool `mapstructure:"gen"` // 新建项目后是否自动执行 gen 命令
RemoteAuthUsername string `mapstructure:"remote-auth-username"` // 远程仓库的认证用户名
RemoteAuthPassword string `mapstructure:"remote-auth-password"` // 远程仓库的认证密码
Frame string `mapstructure:"frame"` // 使用 pzero 内置的框架
Branch string `mapstructure:"branch"` // 使用远程模板仓库的某个分支
Local string `mapstructure:"local"` // 使用本地模板与 branch 对应
Features []string `mapstructure:"features"` // 新建项目使用哪些特性, 灵活构建模板
Ignore []string `mapstructure:"ignore"` // 忽略哪些文件或目录
IgnoreExtra []string `mapstructure:"ignore-extra"` // 忽略哪些额外的文件或目录
ExecutableExtensions []string `mapstructure:"executable-extensions"` // 可执行文件的后缀
}
type TemplateBuildConfig ¶
type TemplateConfig ¶
type TemplateConfig struct {
Init TemplateInitConfig `mapstructure:"init"`
Build TemplateBuildConfig `mapstructure:"build"`
}
type TemplateInitConfig ¶
type ToolVersion ¶
type ToolVersion struct {
ProtocVersion *version.Version
GoctlVersion *version.Version
ProtocGenGoVersion *version.Version
ProtocGenGoGrpcVersion *version.Version
ProtocGenOpenapiv2Version *version.Version
}
var ( ToolVersionOnce sync.Once ToolVersionValue ToolVersion )
type UpgradeConfig ¶
type UpgradeConfig struct {
Channel string `mapstructure:"channel"`
}
Click to show internal directories.
Click to hide internal directories.