Lint / lint (push) Waiting to run
Release / Release (push) Waiting to run
Scan for secrets / test (push) Waiting to run
Snifftest / Run Snifftest (push) Waiting to run
Test / test (push) Waiting to run
Test / test-detectors (push) Waiting to run
Test / test-community (push) Waiting to run
* Init attempt at tui with bubble tea. Co-authored-by: mcastorina <[email protected]> * Add starting and source selection options Co-authored-by: mcastorina <[email protected]> * Rewrite models into a state machine * Update source descriptions * Make subpages implement tea.Model * Rename page0 and page1 to be more descriptive * Adjust styling and adding color consts Co-authored-by: mcastorina <[email protected]> * Add helper generic function to call Update and type cast * Setup plumbing for source configuration page * Use CLI introspection for source configuration (WIP) * Experiment with table view * Replace table with form fields Co-authored-by: mcastorina <[email protected]> * Change 🔒 to 💸 * Copy components from soft-serve Co-authored-by: hxnyk <[email protected]> * Copy styles from soft-serve Co-authored-by: hxnyk <[email protected]> * Copy common from soft-serve Co-authored-by: hxnyk <[email protected]> * Refactor into pages This is still a WIP, but the main structure is there. Co-authored-by: hxnyk <[email protected]> * Trying out selector for wizard intro Co-authored-by: mcastorina <[email protected]> * Use selector with custom View Co-authored-by: hxnyk <[email protected]> * Change Item to be an enum Co-authored-by: hxnyk <[email protected]> * Add link pages Co-authored-by: mcastorina <[email protected]> * Update source select to use selector Co-authored-by: mcastorina <[email protected]> * Delete source configure page and add blank tabs Co-authored-by: hxnyk <[email protected]> * Add tab placeholder pages for configurationi Co-authored-by: mcastorina <[email protected]> * Added headers and style to each tab Co-authored-by: hxnyk <[email protected]> * Update with new sources * Remove kingpin attribute from SourceItem * Add basic form field and source structuring * Hookup git form fields with an underlying textinput component Co-authored-by: hxnyk <[email protected]> * Update forms for git and github Co-authored-by: mcastorina <[email protected]> * Add labels per text input * Add sources and adjust styling * add basic trufflehog configuration page * Add skip button to textinputs component * Emit and handle textinputs skip/submit button commands * Don't quit when q is pressed on the sourceConfigurePage * Build trufflehog command based on source config vals Co-authored-by: mcastorina <[email protected]> * Build flags based on truffle config inputs * Update summary section * Add generated truffle fields Co-authored-by: mcastorina <[email protected]> * update summary to correctly print info * Go back a page when escape key is pressed * WIP run page list Co-authored-by: hxnyk <[email protected]> * Allow running trufflehog from the run page Co-authored-by: hxnyk <[email protected]> * Add option to view help docs Co-authored-by: mcastorina <[email protected]> * comment out unused styles and remove unused types * Capitalize H in TruffleHog * remove unneeded fmt.Sprintf --------- Co-authored-by: mcastorina <[email protected]>
97 lines
2.2 KiB
Go
97 lines
2.2 KiB
Go
package footer
|
|
|
|
import (
|
|
"github.com/charmbracelet/bubbles/help"
|
|
"github.com/charmbracelet/bubbles/key"
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
"github.com/charmbracelet/lipgloss"
|
|
"github.com/trufflesecurity/trufflehog/v3/pkg/tui/common"
|
|
)
|
|
|
|
// ToggleFooterMsg is a message sent to show/hide the footer.
|
|
type ToggleFooterMsg struct{}
|
|
|
|
// Footer is a Bubble Tea model that displays help and other info.
|
|
type Footer struct {
|
|
common common.Common
|
|
help help.Model
|
|
keymap help.KeyMap
|
|
}
|
|
|
|
// New creates a new Footer.
|
|
func New(c common.Common, keymap help.KeyMap) *Footer {
|
|
h := help.New()
|
|
h.Styles.ShortKey = c.Styles.HelpKey
|
|
h.Styles.ShortDesc = c.Styles.HelpValue
|
|
h.Styles.FullKey = c.Styles.HelpKey
|
|
h.Styles.FullDesc = c.Styles.HelpValue
|
|
f := &Footer{
|
|
common: c,
|
|
help: h,
|
|
keymap: keymap,
|
|
}
|
|
f.SetSize(c.Width, c.Height)
|
|
return f
|
|
}
|
|
|
|
// SetSize implements common.Component.
|
|
func (f *Footer) SetSize(width, height int) {
|
|
f.common.SetSize(width, height)
|
|
f.help.Width = width -
|
|
f.common.Styles.Footer.GetHorizontalFrameSize()
|
|
}
|
|
|
|
// Init implements tea.Model.
|
|
func (f *Footer) Init() tea.Cmd {
|
|
return nil
|
|
}
|
|
|
|
// Update implements tea.Model.
|
|
func (f *Footer) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|
return f, nil
|
|
}
|
|
|
|
// View implements tea.Model.
|
|
func (f *Footer) View() string {
|
|
if f.keymap == nil {
|
|
return ""
|
|
}
|
|
s := f.common.Styles.Footer.Copy().
|
|
Width(f.common.Width)
|
|
helpView := f.help.View(f.keymap)
|
|
return f.common.Zone.Mark(
|
|
"footer",
|
|
s.Render(helpView),
|
|
)
|
|
}
|
|
|
|
// ShortHelp returns the short help key bindings.
|
|
func (f *Footer) ShortHelp() []key.Binding {
|
|
return f.keymap.ShortHelp()
|
|
}
|
|
|
|
// FullHelp returns the full help key bindings.
|
|
func (f *Footer) FullHelp() [][]key.Binding {
|
|
return f.keymap.FullHelp()
|
|
}
|
|
|
|
// ShowAll returns whether the full help is shown.
|
|
func (f *Footer) ShowAll() bool {
|
|
return f.help.ShowAll
|
|
}
|
|
|
|
// SetShowAll sets whether the full help is shown.
|
|
func (f *Footer) SetShowAll(show bool) {
|
|
f.help.ShowAll = show
|
|
}
|
|
|
|
// Height returns the height of the footer.
|
|
func (f *Footer) Height() int {
|
|
return lipgloss.Height(f.View())
|
|
}
|
|
|
|
// ToggleFooterCmd sends a ToggleFooterMsg to show/hide the help footer.
|
|
func ToggleFooterCmd() tea.Msg {
|
|
return ToggleFooterMsg{}
|
|
}
|