Skip to content

Commit

Permalink
Change input error messages to make easily understand
Browse files Browse the repository at this point in the history
  • Loading branch information
ssup2 committed Feb 18, 2021
1 parent 2b93315 commit eb06de1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/cmd/kpexec/kpexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,20 @@ func (o *Options) GarbageCollect() error {
}

func (o *Options) Run(args []string, argsLenAtDash int) error {
// Check and set target pod's Name and command
if argsLenAtDash != 1 || len(args) == 1 {
return fmt.Errorf("wrong format")
// Check inputs
// Check pod name by using double dash
if argsLenAtDash == -1 {
return fmt.Errorf("no double dash")
} else if argsLenAtDash == 0 {
return fmt.Errorf("no target pod name")
} else if argsLenAtDash >= 2 {
return fmt.Errorf("wrong pod name")
}
// Chech commands
if len(args) <= 1 {
return fmt.Errorf("no commands")
}

tPodName := args[argsLenAtDash-1]
tPodCmd := args[argsLenAtDash:]

Expand Down

0 comments on commit eb06de1

Please sign in to comment.