Add copy YAML to clipboard
parent
ee1b734464
commit
07f4fdca42
|
|
@ -6,6 +6,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/atotto/clipboard"
|
||||
"github.com/derailed/k9s/internal/config"
|
||||
"github.com/derailed/k9s/internal/ui"
|
||||
"github.com/derailed/tview"
|
||||
|
|
@ -77,6 +78,7 @@ func (v *detailsView) bindKeys() {
|
|||
tcell.KeyTab: ui.NewKeyAction("Next Match", v.nextCmd, false),
|
||||
tcell.KeyBacktab: ui.NewKeyAction("Previous Match", v.prevCmd, false),
|
||||
tcell.KeyCtrlS: ui.NewKeyAction("Save", v.saveCmd, true),
|
||||
ui.KeyC: ui.NewKeyAction("Copy", v.cpCmd, false),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -111,6 +113,16 @@ func (v *detailsView) saveCmd(evt *tcell.EventKey) *tcell.EventKey {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (v *detailsView) cpCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||
log.Debug().Msgf("Copied YAML to clipboard")
|
||||
v.app.Flash().Info("YAML copied to clipboard...")
|
||||
if err := clipboard.WriteAll(v.GetText(true)); err != nil {
|
||||
v.app.Flash().Err(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *detailsView) backCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||
if !v.cmdBuff.Empty() {
|
||||
v.cmdBuff.Reset()
|
||||
|
|
|
|||
Loading…
Reference in New Issue