wip
This commit is contained in:
parent
aeda0158dc
commit
9276a3771f
|
@ -47,7 +47,11 @@ func (add *AddCmd) Parse(main []string, flags map[string]string) error {
|
||||||
as.Main = strings.Join(main[1:], " ")
|
as.Main = strings.Join(main[1:], " ")
|
||||||
}
|
}
|
||||||
for k := range as.Flags {
|
for k := range as.Flags {
|
||||||
if err := as.Set(k, flags[k]); err != nil {
|
v, ok := flags[k]
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := as.Set(k, v); err != nil {
|
||||||
return fmt.Errorf("could not set %s: %v", k, err)
|
return fmt.Errorf("could not set %s: %v", k, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ func TestAddParse(t *testing.T) {
|
||||||
eventRepo := memory.NewEvent()
|
eventRepo := memory.NewEvent()
|
||||||
localRepo := memory.NewLocalID()
|
localRepo := memory.NewLocalID()
|
||||||
syncRepo := memory.NewSync()
|
syncRepo := memory.NewSync()
|
||||||
cmd := command.NewAddCmd(localRepo, eventRepo, syncRepo)
|
|
||||||
for _, tc := range []struct {
|
for _, tc := range []struct {
|
||||||
name string
|
name string
|
||||||
main []string
|
main []string
|
||||||
|
@ -91,9 +90,10 @@ func TestAddParse(t *testing.T) {
|
||||||
// },
|
// },
|
||||||
} {
|
} {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
actErr := cmd.Parse(tc.main, tc.flags)
|
cmd := command.NewAddCmd(localRepo, eventRepo, syncRepo)
|
||||||
if tc.expErr != (actErr != nil) {
|
actErr := cmd.Parse(tc.main, tc.flags) != nil
|
||||||
t.Errorf("exp nil, got %v", actErr)
|
if tc.expErr != actErr {
|
||||||
|
t.Errorf("exp %v, got %v", tc.expErr, actErr)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ func (ft *FlagDate) Set(val string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ft *FlagDate) IsSet() bool {
|
func (ft *FlagDate) IsSet() bool {
|
||||||
return ft.Value.IsZero()
|
return !ft.Value.IsZero()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *FlagDate) Get() any {
|
func (fs *FlagDate) Get() any {
|
||||||
|
@ -79,7 +79,7 @@ func (ft *FlagTime) Set(val string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fd *FlagTime) IsSet() bool {
|
func (fd *FlagTime) IsSet() bool {
|
||||||
return fd.Value.IsZero()
|
return !fd.Value.IsZero()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *FlagTime) Get() any {
|
func (fs *FlagTime) Get() any {
|
||||||
|
|
Loading…
Reference in New Issue