Skip to content

Commit

Permalink
feat: Add default command for interactive shell
Browse files Browse the repository at this point in the history
  • Loading branch information
jpts committed Sep 24, 2022
1 parent 9997fc2 commit ceffecc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var rootCmd = &cobra.Command{
Use: "execws <pod name> [options] -- <cmd>",
Short: "kubectl exec over WebSockets",
Long: `A replacement for "kubectl exec" that works over WebSocket connections.`,
Args: cobra.MinimumNArgs(2),
Args: cobra.MinimumNArgs(1),
SilenceUsage: true,
SilenceErrors: true,
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -52,6 +52,14 @@ var rootCmd = &cobra.Command{
return errors.New("Non pod object not yet supported")
}

if len(command) == 0 {
if tty {
command = []string{"sh", "-c", "exec $(command -v bash || command -v ash || command -v sh)"}
} else {
return errors.New("Please specify a command")
}
}

s := &cliSession{
opts: Options{
Command: command,
Expand Down

0 comments on commit ceffecc

Please sign in to comment.