Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix command when not passing arguments to capture #10

Open
alegrey91 opened this issue Apr 22, 2024 · 0 comments
Open

fix command when not passing arguments to capture #10

alegrey91 opened this issue Apr 22, 2024 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@alegrey91
Copy link
Owner

The program panics when running harpoon capture -f main.doSomething without specifying a command to run.
Eg.

panic: runtime error: index out of range [0] with length 0                                                                                                                                                                                    
                                                                                                                                                                                                                                              
goroutine 1 [running]:                                                                                                                                                                                                                        
github.com/alegrey91/harpoon/cmd.glob..func1(0xc000148100?, {0xc00007a140, 0x0, 0x5})                                                                                                                                                         
        /home/runner/work/harpoon/harpoon/cmd/capture.go:113 +0x13f5                                                                                                                                                                          
github.com/spf13/cobra.(*Command).execute(0x874020, {0xc00007a0f0, 0x5, 0x5})                                                                                                                                                                 
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:987 +0xaa3                                                                                                                                                           
github.com/spf13/cobra.(*Command).ExecuteC(0x874300)                                                                                                                                                                                          
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff                                                                                                                                                          
github.com/spf13/cobra.(*Command).Execute(...)                                                                                                                                                                                                
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039                                                                                                                                                                 
github.com/alegrey91/harpoon/cmd.Execute()                                                                                                                                                                                                    
        /home/runner/work/harpoon/harpoon/cmd/root.go:37 +0x1a                                                                                                                                                                                
main.main()                                                                                                            
        /home/runner/work/harpoon/harpoon/main.go:21 +0xf

This is because the code is not checking if we have enough arguments in input to run.

@alegrey91 alegrey91 added bug Something isn't working good first issue Good for newcomers labels Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant