Skip to content

Commit 1d89fa0

Browse files
committed
fix(main): guard initConfig against missing os.Args[1]
When talm is invoked with no arguments, os.Args only contains the program name. initConfig() runs via cobra.OnInitialize() before normal command handling, so reading os.Args[1] without checking length panics on plain `talm` invocation. Return early when len(os.Args) < 2. Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent 3b4710e commit 1d89fa0

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎main.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ func init() {
131131
}
132132

133133
func initConfig() {
134+
if len(os.Args) < 2 {
135+
return
136+
}
134137
cmdName := os.Args[1]
135138
cmd, _, err := rootCmd.Find([]string{cmdName})
136139
if err != nil || cmd == nil {

0 commit comments

Comments
 (0)