Skip to content

Commit 928948e

Browse files
kitsunoffclaude
andcommitted
fix: skip config loading for completion subcommands
Use CommandPath() instead of cmd.Use to properly detect completion subcommands like "completion bash". Previously, only the leaf command name was checked, causing config loading to fail when Chart.yaml doesn't exist. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d69aa8d commit 928948e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ func init() {
8787
}
8888

8989
// Load config after root detection (skip for init and completion commands)
90-
cmdName := cmd.Use
91-
if !strings.HasPrefix(cmdName, "init") && !strings.HasPrefix(cmdName, "completion") {
90+
// Use CommandPath() to handle subcommands like "completion bash"
91+
cmdPath := cmd.CommandPath() // e.g. "talm completion bash"
92+
if !strings.Contains(cmdPath, " init") && !strings.Contains(cmdPath, " completion") {
9293
configFile := filepath.Join(commands.Config.RootDir, "Chart.yaml")
9394
if err := loadConfig(configFile); err != nil {
9495
return fmt.Errorf("error loading configuration: %w", err)

0 commit comments

Comments
 (0)