mine
derailed 2020-01-25 22:36:13 -07:00
parent 2b34270aa2
commit cfb38b1587
7 changed files with 23 additions and 19 deletions

View File

@ -45,10 +45,10 @@ func init() {
// Klogs (of course) want to print stuff to the screen ;( // Klogs (of course) want to print stuff to the screen ;(
klog.InitFlags(nil) klog.InitFlags(nil)
if err := flag.Set("log_file", config.K9sLogs); err != nil { if err := flag.Set("log_file", "/dev/null"); err != nil {
log.Error().Err(err) log.Error().Err(err)
} }
if err := flag.Set("stderrthreshold", "error"); err != nil { if err := flag.Set("stderrthreshold", "fatal"); err != nil {
log.Error().Err(err) log.Error().Err(err)
} }
if err := flag.Set("alsologtostderr", falseFlag); err != nil { if err := flag.Set("alsologtostderr", falseFlag); err != nil {

View File

@ -123,6 +123,7 @@ func loadK9s(m ResourceMetas) {
Name: "aliases", Name: "aliases",
Kind: "Aliases", Kind: "Aliases",
SingularName: "alias", SingularName: "alias",
Verbs: []string{},
Categories: []string{"k9s"}, Categories: []string{"k9s"},
} }
m[client.NewGVR("contexts")] = metav1.APIResource{ m[client.NewGVR("contexts")] = metav1.APIResource{
@ -130,6 +131,7 @@ func loadK9s(m ResourceMetas) {
Kind: "Contexts", Kind: "Contexts",
SingularName: "context", SingularName: "context",
ShortNames: []string{"ctx"}, ShortNames: []string{"ctx"},
Verbs: []string{},
Categories: []string{"k9s"}, Categories: []string{"k9s"},
} }
m[client.NewGVR("screendumps")] = metav1.APIResource{ m[client.NewGVR("screendumps")] = metav1.APIResource{

View File

@ -98,6 +98,17 @@ func (t *Table) SendKey(evt *tcell.EventKey) {
t.keyboard(evt) t.keyboard(evt)
} }
func (t *Table) filterInput(r rune) {
if !t.cmdBuff.IsActive() {
return
}
t.cmdBuff.Add(r)
t.ClearSelection()
t.doUpdate(t.filtered(t.GetModel().Peek()))
t.UpdateTitle()
t.SelectFirstRow()
}
func (t *Table) keyboard(evt *tcell.EventKey) *tcell.EventKey { func (t *Table) keyboard(evt *tcell.EventKey) *tcell.EventKey {
key := evt.Key() key := evt.Key()
if key == tcell.KeyUp || key == tcell.KeyDown { if key == tcell.KeyUp || key == tcell.KeyDown {
@ -105,14 +116,7 @@ func (t *Table) keyboard(evt *tcell.EventKey) *tcell.EventKey {
} }
if key == tcell.KeyRune { if key == tcell.KeyRune {
if t.SearchBuff().IsActive() { t.filterInput(evt.Rune())
t.SearchBuff().Add(evt.Rune())
t.ClearSelection()
t.doUpdate(t.filtered(t.GetModel().Peek()))
t.UpdateTitle()
t.SelectFirstRow()
return nil
}
key = asKey(evt) key = asKey(evt)
} }
@ -365,7 +369,7 @@ func (t *Table) styleTitle() string {
} }
} }
buff := t.SearchBuff().String() buff := t.cmdBuff.String()
var title string var title string
if ns == client.ClusterScope { if ns == client.ClusterScope {
title = SkinTitle(fmt.Sprintf(TitleFmt, base, rc), t.styles.Frame()) title = SkinTitle(fmt.Sprintf(TitleFmt, base, rc), t.styles.Frame())

View File

@ -9,7 +9,6 @@ import (
"github.com/derailed/k9s/internal/render" "github.com/derailed/k9s/internal/render"
"github.com/derailed/k9s/internal/ui" "github.com/derailed/k9s/internal/ui"
"github.com/gdamore/tcell" "github.com/gdamore/tcell"
"github.com/rs/zerolog/log"
) )
const aliasTitle = "Aliases" const aliasTitle = "Aliases"
@ -48,7 +47,6 @@ func (a *Alias) bindKeys(aa ui.KeyActions) {
} }
func (a *Alias) gotoCmd(evt *tcell.EventKey) *tcell.EventKey { func (a *Alias) gotoCmd(evt *tcell.EventKey) *tcell.EventKey {
log.Debug().Msgf("GOTO CMD")
r, _ := a.GetTable().GetSelection() r, _ := a.GetTable().GetSelection()
if r != 0 { if r != 0 {
s := ui.TrimCell(a.GetTable().SelectTable, r, 1) s := ui.TrimCell(a.GetTable().SelectTable, r, 1)

View File

@ -222,7 +222,7 @@ func (a *App) refreshCluster() {
// Reload alias // Reload alias
go func() { go func() {
if err := a.command.Reset(); err != nil { if err := a.command.Reset(false); err != nil {
log.Error().Err(err).Msgf("Command reset failed") log.Error().Err(err).Msgf("Command reset failed")
} }
}() }()
@ -256,7 +256,7 @@ func (a *App) switchCtx(name string, loadPods bool) error {
} }
a.initFactory(ns) a.initFactory(ns)
if err := a.command.Reset(); err != nil { if err := a.command.Reset(true); err != nil {
return err return err
} }
a.Config.Reset() a.Config.Reset()

View File

@ -46,11 +46,13 @@ func (c *Command) Init() error {
} }
// Reset resets Command and reload aliases. // Reset resets Command and reload aliases.
func (c *Command) Reset() error { func (c *Command) Reset(clear bool) error {
c.mx.Lock() c.mx.Lock()
defer c.mx.Unlock() defer c.mx.Unlock()
if clear {
c.alias.Clear() c.alias.Clear()
}
if _, err := c.alias.Ensure(); err != nil { if _, err := c.alias.Ensure(); err != nil {
return err return err
} }

View File

@ -191,9 +191,7 @@ func (t *Table) eraseCmd(evt *tcell.EventKey) *tcell.EventKey {
} }
func (t *Table) activateCmd(evt *tcell.EventKey) *tcell.EventKey { func (t *Table) activateCmd(evt *tcell.EventKey) *tcell.EventKey {
log.Debug().Msgf("Table filter activated!")
if t.app.InCmdMode() { if t.app.InCmdMode() {
log.Debug().Msgf("App Is in Command mode!")
return evt return evt
} }
t.app.Flash().Info("Filter mode activated.") t.app.Flash().Info("Filter mode activated.")