move description param from option to param
This commit is contained in:
@@ -231,7 +231,7 @@ func (v View) ParentStruct() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v View) Description() string {
|
func (v View) Description() string {
|
||||||
return option.DataDescription(v.Option)
|
return param.Description(v.Option)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v View) Default() any {
|
func (v View) Default() any {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package group
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"gitoa.ru/go-4devs/config"
|
"gitoa.ru/go-4devs/config"
|
||||||
"gitoa.ru/go-4devs/config/definition/option"
|
|
||||||
"gitoa.ru/go-4devs/config/param"
|
"gitoa.ru/go-4devs/config/param"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,7 +11,7 @@ func New(name, desc string, opts ...config.Option) *Group {
|
|||||||
group := Group{
|
group := Group{
|
||||||
name: name,
|
name: name,
|
||||||
opts: opts,
|
opts: opts,
|
||||||
Params: param.New(option.Description(desc)),
|
Params: param.New(param.WithDescription(desc)),
|
||||||
}
|
}
|
||||||
|
|
||||||
return &group
|
return &group
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"gitoa.ru/go-4devs/config/definition/group"
|
"gitoa.ru/go-4devs/config/definition/group"
|
||||||
"gitoa.ru/go-4devs/config/definition/option"
|
"gitoa.ru/go-4devs/config/param"
|
||||||
"gitoa.ru/go-4devs/config/test/require"
|
"gitoa.ru/go-4devs/config/test/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ func TestGroupWith(t *testing.T) {
|
|||||||
const descrition = "group description"
|
const descrition = "group description"
|
||||||
|
|
||||||
gr := group.New("test", "test desc")
|
gr := group.New("test", "test desc")
|
||||||
gr = gr.With(option.Description(descrition))
|
gr = gr.With(param.WithDescription(descrition))
|
||||||
|
|
||||||
require.Equal(t, descrition, option.DataDescription(gr))
|
require.Equal(t, descrition, param.Description(gr))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
var _ config.Option = New("", "", nil)
|
var _ config.Option = New("", "", nil)
|
||||||
|
|
||||||
func New(name, desc string, vtype any, opts ...param.Option) Option {
|
func New(name, desc string, vtype any, opts ...param.Option) Option {
|
||||||
opts = append(opts, Description(desc), WithType(vtype))
|
opts = append(opts, param.WithDescription(desc), WithType(vtype))
|
||||||
res := Option{
|
res := Option{
|
||||||
name: name,
|
name: name,
|
||||||
Params: param.New(opts...),
|
Params: param.New(opts...),
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ type key int
|
|||||||
const (
|
const (
|
||||||
paramHidden key = iota + 1
|
paramHidden key = iota + 1
|
||||||
paramDefault
|
paramDefault
|
||||||
paramDesc
|
|
||||||
paramRequired
|
paramRequired
|
||||||
paramSlice
|
paramSlice
|
||||||
paramBool
|
paramBool
|
||||||
@@ -72,10 +71,9 @@ func Default(in any) param.Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: use param.WithDescription.
|
||||||
func Description(in string) param.Option {
|
func Description(in string) param.Option {
|
||||||
return func(v param.Params) param.Params {
|
return param.WithDescription(in)
|
||||||
return param.With(v, paramDesc, in)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func HasDefaut(fn param.Params) bool {
|
func HasDefaut(fn param.Params) bool {
|
||||||
@@ -118,8 +116,7 @@ func IsRequired(fn param.Params) bool {
|
|||||||
return ok && data
|
return ok && data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: use param.Description.
|
||||||
func DataDescription(fn param.Params) string {
|
func DataDescription(fn param.Params) string {
|
||||||
data, _ := param.String(fn, paramDesc)
|
return param.Description(fn)
|
||||||
|
|
||||||
return data
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package proto
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"gitoa.ru/go-4devs/config"
|
"gitoa.ru/go-4devs/config"
|
||||||
"gitoa.ru/go-4devs/config/definition/option"
|
|
||||||
"gitoa.ru/go-4devs/config/key"
|
"gitoa.ru/go-4devs/config/key"
|
||||||
"gitoa.ru/go-4devs/config/param"
|
"gitoa.ru/go-4devs/config/param"
|
||||||
)
|
)
|
||||||
@@ -13,7 +12,7 @@ func New(name string, desc string, opts ...config.Option) Proto {
|
|||||||
return Proto{
|
return Proto{
|
||||||
name: key.Wild(name),
|
name: key.Wild(name),
|
||||||
opts: opts,
|
opts: opts,
|
||||||
Params: param.New(option.Description(desc)),
|
Params: param.New(param.WithDescription(desc)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ type key int
|
|||||||
const (
|
const (
|
||||||
paramTimeFormat key = iota + 1
|
paramTimeFormat key = iota + 1
|
||||||
paramType
|
paramType
|
||||||
|
paramDescription
|
||||||
)
|
)
|
||||||
|
|
||||||
func WithTimeFormat(format string) Option {
|
func WithTimeFormat(format string) Option {
|
||||||
@@ -28,3 +29,15 @@ func Type(fn Params) any {
|
|||||||
|
|
||||||
return param
|
return param
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithDescription(in string) Option {
|
||||||
|
return func(p Params) Params {
|
||||||
|
return With(p, paramDescription, in)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Description(fn Params) string {
|
||||||
|
data, _ := String(fn, paramDescription)
|
||||||
|
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user