update lint
This commit is contained in:
1
app.go
1
app.go
@@ -130,6 +130,7 @@ func (a *App) list(ctx context.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
in := &input.Wrap{
|
in := &input.Wrap{
|
||||||
Input: a.in,
|
Input: a.in,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ import (
|
|||||||
|
|
||||||
func TestCreateUser(t *testing.T) {
|
func TestCreateUser(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
in := &input.Array{}
|
|
||||||
in.SetArgument("username", "andrey")
|
|
||||||
buf := bytes.Buffer{}
|
buf := bytes.Buffer{}
|
||||||
out := output.Buffer(&buf)
|
out := output.Buffer(&buf)
|
||||||
|
in := &input.Array{}
|
||||||
|
in.SetArgument("username", "andrey")
|
||||||
|
|
||||||
err := console.Run(ctx, command.CreateUser(false), in, out)
|
err := console.Run(ctx, command.CreateUser(false), in, out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -58,14 +58,14 @@ func (a *Array) Argument(_ context.Context, name string) value.Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *Array) Bind(ctx context.Context, d *Definition) error {
|
func (a *Array) Bind(ctx context.Context, d *Definition) error {
|
||||||
if err := a.bindArguments(ctx, d); err != nil {
|
if err := a.bindArguments(d); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.bindOption(ctx, d)
|
return a.bindOption(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Array) bindOption(ctx context.Context, def *Definition) error {
|
func (a *Array) bindOption(def *Definition) error {
|
||||||
for _, name := range def.Options() {
|
for _, name := range def.Options() {
|
||||||
opt, err := def.Option(name)
|
opt, err := def.Option(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -77,6 +77,7 @@ func (a *Array) bindOption(ctx context.Context, def *Definition) error {
|
|||||||
switch {
|
switch {
|
||||||
case opt.HasDefault():
|
case opt.HasDefault():
|
||||||
a.defaults.SetOption(name, opt.Default)
|
a.defaults.SetOption(name, opt.Default)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
case opt.IsRequired():
|
case opt.IsRequired():
|
||||||
return errs.Option(name, errs.ErrRequired)
|
return errs.Option(name, errs.ErrRequired)
|
||||||
@@ -85,17 +86,17 @@ func (a *Array) bindOption(ctx context.Context, def *Definition) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.SetOption(name, v)
|
||||||
|
|
||||||
if err := opt.Validate(v); err != nil {
|
if err := opt.Validate(v); err != nil {
|
||||||
return errs.Option(name, err)
|
return errs.Option(name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
a.SetOption(name, v)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Array) bindArguments(ctx context.Context, def *Definition) error {
|
func (a *Array) bindArguments(def *Definition) error {
|
||||||
for pos, name := range def.Arguments() {
|
for pos, name := range def.Arguments() {
|
||||||
arg, err := def.Argument(pos)
|
arg, err := def.Argument(pos)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -107,6 +108,7 @@ func (a *Array) bindArguments(ctx context.Context, def *Definition) error {
|
|||||||
switch {
|
switch {
|
||||||
case arg.HasDefault():
|
case arg.HasDefault():
|
||||||
a.defaults.SetArgument(name, arg.Default)
|
a.defaults.SetArgument(name, arg.Default)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
case arg.IsRequired():
|
case arg.IsRequired():
|
||||||
return errs.Argument(name, errs.ErrRequired)
|
return errs.Argument(name, errs.ErrRequired)
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Empty = &empty{}
|
// nolint: gochecknoglobals
|
||||||
|
var (
|
||||||
|
Empty = &empty{}
|
||||||
|
)
|
||||||
|
|
||||||
func IsEmpty(v Value) bool {
|
func IsEmpty(v Value) bool {
|
||||||
return v == Empty
|
return v == Empty
|
||||||
|
|||||||
Reference in New Issue
Block a user