A few various changes
- Fixed the '-local' flag to accept host and port - Added a '-debug' flag to accept a file to write debug log messages - Added some logic which will force the dark background flag on if MacOS is in dark mode
This commit is contained in:
parent
47e404aff7
commit
41af399215
18 changed files with 191 additions and 68 deletions
|
|
@ -1,18 +1,18 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/lmika/awstools/internal/dynamo-browse/models"
|
||||
)
|
||||
|
||||
type NewResultSet struct {
|
||||
ResultSet *models.ResultSet
|
||||
ResultSet *models.ResultSet
|
||||
statusMessage string
|
||||
}
|
||||
|
||||
func (rs NewResultSet) StatusMessage() string {
|
||||
return fmt.Sprintf("%d items returned", len(rs.ResultSet.Items()))
|
||||
//return fmt.Sprintf("%d items returned", len(rs.ResultSet.Items()))
|
||||
return rs.statusMessage
|
||||
}
|
||||
|
||||
type SetReadWrite struct {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package controllers
|
|||
import (
|
||||
"context"
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/lmika/awstools/internal/common/ui/events"
|
||||
"github.com/lmika/awstools/internal/dynamo-browse/models"
|
||||
|
|
@ -126,16 +127,23 @@ func (c *TableReadController) doScan(ctx context.Context, resultSet *models.Resu
|
|||
return c.setResultSetAndFilter(newResultSet, c.state.Filter())
|
||||
}
|
||||
|
||||
//func (c *TableReadController) ResultSet() *models.ResultSet {
|
||||
// c.mutex.Lock()
|
||||
// defer c.mutex.Unlock()
|
||||
//
|
||||
// return c.resultSet
|
||||
//}
|
||||
|
||||
func (c *TableReadController) setResultSetAndFilter(resultSet *models.ResultSet, filter string) tea.Msg {
|
||||
c.state.setResultSetAndFilter(resultSet, filter)
|
||||
return NewResultSet{resultSet}
|
||||
|
||||
var statusMessage string
|
||||
if filter != "" {
|
||||
var filteredCount int
|
||||
for i := range resultSet.Items() {
|
||||
if !resultSet.Hidden(i) {
|
||||
filteredCount += 1
|
||||
}
|
||||
}
|
||||
statusMessage = fmt.Sprintf("%d of %d items returned", filteredCount, len(resultSet.Items()))
|
||||
} else {
|
||||
statusMessage = fmt.Sprintf("%d items returned", len(resultSet.Items()))
|
||||
}
|
||||
|
||||
return NewResultSet{resultSet, statusMessage}
|
||||
}
|
||||
|
||||
func (c *TableReadController) Unmark() tea.Cmd {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func (twc *TableWriteController) NewItem() tea.Cmd {
|
|||
Dirty: true,
|
||||
})
|
||||
})
|
||||
return NewResultSet{twc.state.ResultSet()}
|
||||
return NewResultSet{twc.state.ResultSet(), "New item added"}
|
||||
}
|
||||
|
||||
return keyPrompts.next()
|
||||
|
|
|
|||
|
|
@ -128,9 +128,7 @@ func (m *Model) setLeftmostDisplayedColumn(newCol int) {
|
|||
} else {
|
||||
m.colOffset = newCol
|
||||
}
|
||||
// TEMP
|
||||
m.table.GoDown()
|
||||
m.table.GoUp()
|
||||
m.table.UpdateView()
|
||||
}
|
||||
|
||||
func (m *Model) View() string {
|
||||
|
|
@ -172,15 +170,6 @@ func (m *Model) rebuildTable() {
|
|||
|
||||
m.rows = newRows
|
||||
newTbl.SetRows(newRows)
|
||||
/*
|
||||
for newTbl.Cursor() != m.table.Cursor() {
|
||||
if newTbl.Cursor() < m.table.Cursor() {
|
||||
newTbl.GoDown()
|
||||
} else if newTbl.Cursor() > m.table.Cursor() {
|
||||
newTbl.GoUp()
|
||||
}
|
||||
}
|
||||
*/
|
||||
m.table = newTbl
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
var (
|
||||
markedRowStyle = lipgloss.NewStyle().
|
||||
Background(lipgloss.AdaptiveColor{Dark: "#e1e1e1", Light: "#414141"})
|
||||
Background(lipgloss.AdaptiveColor{Light: "#e1e1e1", Dark: "#414141"})
|
||||
dirtyRowStyle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("#e13131"))
|
||||
newRowStyle = lipgloss.NewStyle().
|
||||
|
|
@ -60,6 +60,8 @@ func (mtr itemTableRow) Render(w io.Writer, model table.Model, index int) {
|
|||
if mi := r.MetaInfo(); mi != "" {
|
||||
sb.WriteString(metaInfoStyle.Render(mi))
|
||||
}
|
||||
} else {
|
||||
sb.WriteString(metaInfoStyle.Render("~"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue