ssm-browse: added cd command

Also came up with an approach for dealing with commands that will probably work with contexts
This commit is contained in:
Leon Mika 2022-03-29 10:29:25 +11:00
parent 0b745a6dfa
commit f6f06eb22d
13 changed files with 142 additions and 37 deletions

View file

@ -19,7 +19,7 @@ type Model struct {
}
func New() *Model {
frameTitle := frame.NewFrameTitle("SSM", true)
frameTitle := frame.NewFrameTitle("SSM: /", true)
table := table.New([]string{"name", "type", "value"}, 0, 0)
return &Model{
@ -28,6 +28,10 @@ func New() *Model {
}
}
func (m *Model) SetPrefix(newPrefix string) {
m.frameTitle.SetTitle("SSM: " + newPrefix)
}
func (m *Model) SetParameters(parameters *models.SSMParameters) {
m.parameters = parameters
cols := []string{"name", "type", "value"}

View file

@ -5,6 +5,7 @@ import (
table "github.com/calyptia/go-bubble-table"
"github.com/lmika/awstools/internal/ssm-browse/models"
"io"
"strings"
)
type itemTableRow struct {
@ -12,7 +13,8 @@ type itemTableRow struct {
}
func (mtr itemTableRow) Render(w io.Writer, model table.Model, index int) {
line := fmt.Sprintf("%s\t%s\t%s", mtr.item.Name, "String", mtr.item.Value)
firstLine := strings.SplitN(mtr.item.Value, "\n", 2)[0]
line := fmt.Sprintf("%s\t%s\t%s", mtr.item.Name, "String", firstLine)
if index == model.Cursor() {
fmt.Fprintln(w, model.Styles.SelectedRow.Render(line))