Skip to content

Commit

Permalink
issue #5: implement panic command
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Apr 23, 2021
1 parent 2734949 commit 62e7f9e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions internal/cmd/demo/panic.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
package demo

import "github.com/spf13/cobra"
import (
"strings"

"github.com/spf13/cobra"
)

// Panic returns a demo cobra.Command to raise a panic.
//
// $ go run main.go panic
// $ go run main.go panic [message]
//
func Panic() *cobra.Command {
command := cobra.Command{
Use: "panic",
Args: cobra.NoArgs,
Use: "panic",
Run: func(cmd *cobra.Command, args []string) {
panic("unexpected panic")
if len(args) == 0 {
args = []string{"unexpected panic"}
}
panic(strings.Join(args, " "))
},
}

Expand Down

0 comments on commit 62e7f9e

Please sign in to comment.