Skip to content

Commit 3ee2e2a

Browse files
authored
feat: flag to cd to support bundle dir on starting shell (#176)
Signed-off-by: Evans Mungai <evans@replicated.com>
1 parent 3418626 commit 3ee2e2a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cli/shell.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,15 @@ func ShellCmd() *cobra.Command {
153153
fmt.Printf("sbctl shell exited\n")
154154
}()
155155

156+
cmds := []string{
157+
fmt.Sprintf("export KUBECONFIG=%s", kubeConfig),
158+
}
159+
if v.GetBool("cd-bundle") {
160+
cmds = append(cmds, fmt.Sprintf("cd %s", bundleDir))
161+
}
162+
156163
// Setup the shell
157-
setupCmd := fmt.Sprintf("export KUBECONFIG=%s\n", kubeConfig)
164+
setupCmd := strings.Join(cmds, "\n") + "\n"
158165
_, _ = io.WriteString(shellPty, setupCmd)
159166
_, _ = io.CopyN(io.Discard, shellPty, 2*int64(len(setupCmd))) // Don't print to screen, terminal will echo anyway
160167

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

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

0 commit comments

Comments
 (0)