@@ -9,23 +9,24 @@ import (
99
1010 tea "github.com/charmbracelet/bubbletea"
1111 "github.com/charmbracelet/lipgloss"
12+ "github.com/larkinwc/gitlab-runner-tui/pkg/config"
1213 "github.com/larkinwc/gitlab-runner-tui/pkg/runner"
1314 "github.com/larkinwc/gitlab-runner-tui/pkg/ui"
1415)
1516
1617type model struct {
17- tabs []string
18- activeTab int
19- runnersView * ui.RunnersView
20- logsView * ui.LogsView
21- configView * ui.ConfigView
22- systemView * ui.SystemView
23- historyView * ui.HistoryView
24- width int
25- height int
26- quitting bool
27- debugMode bool
28- initialized map [int ]bool
18+ tabs []string
19+ activeTab int
20+ runnersView * ui.RunnersView
21+ logsView * ui.LogsView
22+ configView * ui.ConfigView
23+ systemView * ui.SystemView
24+ historyView * ui.HistoryView
25+ width int
26+ height int
27+ quitting bool
28+ debugMode bool
29+ initialized map [int ]bool
2930}
3031
3132func initialModel (configPath string , debugMode bool ) model {
@@ -174,35 +175,35 @@ func (m model) View() string {
174175 }
175176
176177 statusBar := m .renderStatusBar ()
177-
178+
178179 // Calculate available height for content
179180 tabBarHeight := lipgloss .Height (tabBar )
180181 statusBarHeight := lipgloss .Height (statusBar )
181182 availableHeight := m .height - tabBarHeight - statusBarHeight - 1
182-
183+
183184 // Ensure we have positive height
184185 if availableHeight < 1 {
185186 availableHeight = 1
186187 }
187-
188+
188189 // Ensure content doesn't overflow
189190 contentLines := strings .Split (content , "\n " )
190191 if len (contentLines ) > availableHeight && availableHeight > 0 {
191192 content = strings .Join (contentLines [:availableHeight ], "\n " )
192193 }
193-
194+
194195 // Calculate padding
195196 contentHeight := lipgloss .Height (content )
196197 paddingHeight := m .height - tabBarHeight - contentHeight - statusBarHeight
197198 if paddingHeight < 0 {
198199 paddingHeight = 0
199200 }
200-
201+
201202 padding := ""
202203 if paddingHeight > 0 {
203204 padding = strings .Repeat ("\n " , paddingHeight )
204205 }
205-
206+
206207 return lipgloss .JoinVertical (
207208 lipgloss .Left ,
208209 tabBar ,
@@ -232,18 +233,18 @@ func (m model) renderStatusBar() string {
232233 Background (ui .ColorPrimary ).
233234 Foreground (ui .ColorBg ).
234235 Padding (0 , 1 )
235-
236+
236237 helpStyle := lipgloss .NewStyle ().
237238 Background (ui .ColorSecondary ).
238239 Foreground (ui .ColorBg ).
239240 Padding (0 , 1 )
240-
241+
241242 // Build contextual help based on active tab
242243 var commands []string
243-
244+
244245 // Global commands
245246 commands = append (commands , "Tab/Shift+Tab: Switch tabs" , "1-5: Jump to tab" , "q: Quit" )
246-
247+
247248 // Tab-specific commands
248249 switch m .activeTab {
249250 case 0 : // Runners
@@ -257,17 +258,17 @@ func (m model) renderStatusBar() string {
257258 case 4 : // History
258259 commands = append (commands , "↑/↓: Navigate" , "r: Refresh" )
259260 }
260-
261+
261262 // Add debug mode indicator if enabled
262263 statusText := ""
263264 if m .debugMode {
264265 statusText = " [DEBUG] "
265266 }
266-
267+
267268 // Combine status and help
268269 status := statusStyle .Render (statusText + m .tabs [m .activeTab ])
269270 help := helpStyle .Render (strings .Join (commands , " • " ))
270-
271+
271272 // Fill the remaining width
272273 statusBarContent := lipgloss .JoinHorizontal (lipgloss .Top , status , " " , help )
273274 remainingWidth := m .width - lipgloss .Width (statusBarContent )
@@ -277,42 +278,40 @@ func (m model) renderStatusBar() string {
277278 Render (strings .Repeat (" " , remainingWidth ))
278279 statusBarContent = lipgloss .JoinHorizontal (lipgloss .Top , statusBarContent , filler )
279280 }
280-
281+
281282 return statusBarContent
282283}
283284
284285func main () {
285286 var configPath string
286287 var debugMode bool
287288 var showHelp bool
288-
289- defaultConfig := "/etc/gitlab-runner/config.toml"
290-
291- flag .StringVar (& configPath , "config" , defaultConfig , "Path to GitLab Runner config file" )
289+
290+ flag .StringVar (& configPath , "config" , config .DefaultConfigPath , "Path to GitLab Runner config file" )
292291 flag .BoolVar (& debugMode , "debug" , false , "Enable debug mode for verbose logging" )
293292 flag .BoolVar (& showHelp , "help" , false , "Show help information" )
294293 flag .BoolVar (& showHelp , "h" , false , "Show help information" )
295-
294+
296295 flag .Usage = func () {
297296 fmt .Fprintf (os .Stderr , "GitLab Runner TUI - Terminal User Interface for managing GitLab runners\n \n " )
298297 fmt .Fprintf (os .Stderr , "Usage: %s [options]\n \n " , os .Args [0 ])
299298 fmt .Fprintf (os .Stderr , "Options:\n " )
300299 flag .PrintDefaults ()
301300 fmt .Fprintf (os .Stderr , "\n Default config paths checked:\n " )
302- fmt .Fprintf (os .Stderr , " 1. %s (system-wide)\n " , defaultConfig )
301+ fmt .Fprintf (os .Stderr , " 1. %s (system-wide)\n " , config . DefaultConfigPath )
303302 fmt .Fprintf (os .Stderr , " 2. $HOME/.gitlab-runner/config.toml (user-specific)\n " )
304303 fmt .Fprintf (os .Stderr , "\n If no config is found at the default path, the user-specific path is tried.\n " )
305304 }
306-
305+
307306 flag .Parse ()
308-
307+
309308 if showHelp {
310309 flag .Usage ()
311310 os .Exit (0 )
312311 }
313312
314313 // Check if config exists at specified path
315- if configPath == defaultConfig {
314+ if configPath == config . DefaultConfigPath {
316315 if _ , err := os .Stat (configPath ); os .IsNotExist (err ) {
317316 altPath := os .ExpandEnv ("$HOME/.gitlab-runner/config.toml" )
318317 if _ , err := os .Stat (altPath ); err == nil {
0 commit comments