Skip to content

Commit

Permalink
feat: flag to cd to support bundle dir on starting shell (#176)
Browse files Browse the repository at this point in the history
Signed-off-by: Evans Mungai <[email protected]>
  • Loading branch information
banjoh authored Aug 7, 2024
1 parent 3418626 commit 3ee2e2a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cli/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,15 @@ func ShellCmd() *cobra.Command {
fmt.Printf("sbctl shell exited\n")
}()

cmds := []string{
fmt.Sprintf("export KUBECONFIG=%s", kubeConfig),
}
if v.GetBool("cd-bundle") {
cmds = append(cmds, fmt.Sprintf("cd %s", bundleDir))
}

// Setup the shell
setupCmd := fmt.Sprintf("export KUBECONFIG=%s\n", kubeConfig)
setupCmd := strings.Join(cmds, "\n") + "\n"
_, _ = io.WriteString(shellPty, setupCmd)
_, _ = io.CopyN(io.Discard, shellPty, 2*int64(len(setupCmd))) // Don't print to screen, terminal will echo anyway

Expand All @@ -168,6 +175,7 @@ func ShellCmd() *cobra.Command {

cmd.Flags().StringP("support-bundle-location", "s", "", "path to support bundle archive, directory, or URL")
cmd.Flags().StringP("token", "t", "", "API token for authentication when fetching on-line bundles")
cmd.Flags().Bool("cd-bundle", false, "Change directory to the support bundle path after starting the shell")
cmd.Flags().Bool("debug", false, "enable debug logging. This will include HTTP response bodies in logs.")
return cmd
}

0 comments on commit 3ee2e2a

Please sign in to comment.