32 lines
755 B
Go
32 lines
755 B
Go
|
package cmdpacks
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"github.com/lmika/dynamo-browse/internal/common/ui/commandctrl"
|
||
|
"github.com/lmika/dynamo-browse/internal/dynamo-browse/controllers"
|
||
|
"github.com/pkg/errors"
|
||
|
"log"
|
||
|
)
|
||
|
|
||
|
type resultSetPVar struct {
|
||
|
state *controllers.State
|
||
|
readController *controllers.TableReadController
|
||
|
}
|
||
|
|
||
|
func (rs resultSetPVar) Get(ctx context.Context) (any, error) {
|
||
|
return ResultSetProxy{rs.state.ResultSet()}, nil
|
||
|
}
|
||
|
|
||
|
func (rs resultSetPVar) Set(ctx context.Context, value any) error {
|
||
|
rsVal, ok := value.(ResultSetProxy)
|
||
|
if !ok {
|
||
|
return errors.New("new value to @resultset is not a result set")
|
||
|
}
|
||
|
|
||
|
log.Printf("type = %T", rsVal.RS)
|
||
|
|
||
|
msg := rs.readController.SetResultSet(rsVal.RS)
|
||
|
commandctrl.PostMsg(ctx, msg)
|
||
|
return nil
|
||
|
}
|