mirror of
https://github.com/Gu1llaum-3/sshm.git
synced 2025-10-21 18:37:23 +02:00
Merge 3bd412aba94465db538782d533ef0874b69268ea into 825c534ebe1b5683a57522329e26ad37a182bead
This commit is contained in:
commit
149dda6a23
@ -24,6 +24,9 @@ var AppVersion = "dev"
|
|||||||
// configFile holds the path to the SSH config file
|
// configFile holds the path to the SSH config file
|
||||||
var configFile string
|
var configFile string
|
||||||
|
|
||||||
|
// searchMode enables the focus on search mode at startup
|
||||||
|
var searchMode bool
|
||||||
|
|
||||||
// RootCmd is the base command when called without any subcommands
|
// RootCmd is the base command when called without any subcommands
|
||||||
var RootCmd = &cobra.Command{
|
var RootCmd = &cobra.Command{
|
||||||
Use: "sshm [host]",
|
Use: "sshm [host]",
|
||||||
@ -97,7 +100,7 @@ func runInteractiveMode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run the interactive TUI
|
// Run the interactive TUI
|
||||||
if err := ui.RunInteractiveMode(hosts, configFile, AppVersion); err != nil {
|
if err := ui.RunInteractiveMode(hosts, configFile, searchMode, AppVersion); err != nil {
|
||||||
log.Fatalf("Error running interactive mode: %v", err)
|
log.Fatalf("Error running interactive mode: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,6 +222,7 @@ func Execute() {
|
|||||||
func init() {
|
func init() {
|
||||||
// Add the config file flag
|
// Add the config file flag
|
||||||
RootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "", "SSH config file to use (default: ~/.ssh/config)")
|
RootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "", "SSH config file to use (default: ~/.ssh/config)")
|
||||||
|
RootCmd.PersistentFlags().BoolVarP(&searchMode, "search", "s", false, "Focus on search input at startup")
|
||||||
|
|
||||||
// Set custom version template with update check
|
// Set custom version template with update check
|
||||||
RootCmd.SetVersionTemplate(getVersionWithUpdateCheck())
|
RootCmd.SetVersionTemplate(getVersionWithUpdateCheck())
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// NewModel creates a new TUI model with the given SSH hosts
|
// NewModel creates a new TUI model with the given SSH hosts
|
||||||
func NewModel(hosts []config.SSHHost, configFile, currentVersion string) Model {
|
func NewModel(hosts []config.SSHHost, configFile string, searchMode bool, currentVersion string) Model {
|
||||||
// Load application configuration
|
// Load application configuration
|
||||||
appConfig, err := config.LoadAppConfig()
|
appConfig, err := config.LoadAppConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -54,6 +54,7 @@ func NewModel(hosts []config.SSHHost, configFile, currentVersion string) Model {
|
|||||||
height: 24,
|
height: 24,
|
||||||
ready: false,
|
ready: false,
|
||||||
viewMode: ViewList,
|
viewMode: ViewList,
|
||||||
|
searchMode: searchMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort hosts according to the default sort mode
|
// Sort hosts according to the default sort mode
|
||||||
@ -64,6 +65,9 @@ func NewModel(hosts []config.SSHHost, configFile, currentVersion string) Model {
|
|||||||
ti.Placeholder = "Search hosts or tags..."
|
ti.Placeholder = "Search hosts or tags..."
|
||||||
ti.CharLimit = 50
|
ti.CharLimit = 50
|
||||||
ti.Width = 25
|
ti.Width = 25
|
||||||
|
if searchMode {
|
||||||
|
ti.Focus()
|
||||||
|
}
|
||||||
|
|
||||||
// Use dynamic column width calculation (will fallback to static if width not available)
|
// Use dynamic column width calculation (will fallback to static if width not available)
|
||||||
nameWidth, hostnameWidth, tagsWidth, lastLoginWidth := m.calculateDynamicColumnWidths(sortedHosts)
|
nameWidth, hostnameWidth, tagsWidth, lastLoginWidth := m.calculateDynamicColumnWidths(sortedHosts)
|
||||||
@ -147,8 +151,8 @@ func NewModel(hosts []config.SSHHost, configFile, currentVersion string) Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RunInteractiveMode starts the interactive TUI interface
|
// RunInteractiveMode starts the interactive TUI interface
|
||||||
func RunInteractiveMode(hosts []config.SSHHost, configFile, currentVersion string) error {
|
func RunInteractiveMode(hosts []config.SSHHost, configFile string, searchMode bool, currentVersion string) error {
|
||||||
m := NewModel(hosts, configFile, currentVersion)
|
m := NewModel(hosts, configFile, searchMode, currentVersion)
|
||||||
|
|
||||||
// Start the application in alt screen mode for clean output
|
// Start the application in alt screen mode for clean output
|
||||||
p := tea.NewProgram(m, tea.WithAltScreen())
|
p := tea.NewProgram(m, tea.WithAltScreen())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user