Skip to content

Commit e9a9a4f

Browse files
authored
Add deprecation warning on shell -- cmd (#502)
## Summary TSIA To be merged after #503. ## How was it tested? ``` > ./devbox shell -- hello [Warning] "devbox shell -- <cmd>" is deprecated and will disappear in a future version. Use "devbox run -- <cmd>" instead Installing nix packages. This may take a while... done. Hello, world! ``` ``` > ./devbox shell -q -- hello Hello, world! ``` ``` > ./devbox shell --help Start a new shell with access to your packages. The shell will be started using the devbox.json found in the --config flag directory. If --config isn't set, then devbox recursively searches the current directory and its parents. [Deprecated] If invoked as devbox shell -- <cmd>, devbox will run the command in a shell and then exit. This behavior is deprecated and will be removed. Please use devbox run -- <cmd> instead. Usage: devbox shell -- [<cmd>] [flags] Flags: -c, --config string path to directory containing a devbox.json config file -h, --help help for shell --print-env print script to setup shell environment Global Flags: -q, --quiet suppresses logs. ```
1 parent 5ea67ad commit e9a9a4f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

internal/boxcli/shell.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package boxcli
66
import (
77
"fmt"
88

9+
"github.com/fatih/color"
910
"github.com/pkg/errors"
1011
"github.com/spf13/cobra"
1112
"go.jetpack.io/devbox"
@@ -21,12 +22,12 @@ func ShellCmd() *cobra.Command {
2122
flags := shellCmdFlags{}
2223
command := &cobra.Command{
2324
Use: "shell -- [<cmd>]",
24-
Short: "Start a new shell or run a command with access to your packages",
25-
Long: "Start a new shell or run a command with access to your packages.\n\n" +
26-
"If invoked without `cmd`, devbox will start an interactive shell.\n" +
27-
"If invoked with a `cmd`, devbox will run the command in a shell and then exit.\n" +
28-
"In both cases, the shell will be started using the devbox.json found in the --config flag directory. " +
29-
"If --config isn't set, then devbox recursively searches the current directory and its parents.",
25+
Short: "Start a new shell with access to your packages",
26+
Long: "Start a new shell with access to your packages.\n\n" +
27+
"The shell will be started using the devbox.json found in the --config flag directory. " +
28+
"If --config isn't set, then devbox recursively searches the current directory and its parents.\n\n" +
29+
"[Deprecated] If invoked as devbox shell -- <cmd>, devbox will run the command in a shell and then exit. " +
30+
"This behavior is deprecated and will be removed. Please use devbox run -- <cmd> instead.",
3031
Args: validateShellArgs,
3132
PreRunE: ensureNixInstalled,
3233
RunE: func(cmd *cobra.Command, args []string) error {
@@ -68,6 +69,9 @@ func runShellCmd(cmd *cobra.Command, args []string, flags shellCmdFlags) error {
6869
}
6970

7071
if len(cmds) > 0 {
72+
fmt.Fprint(cmd.ErrOrStderr(),
73+
color.HiYellowString("[Warning] \"devbox shell -- <cmd>\" is deprecated and will disappear "+
74+
"in a future version. Use \"devbox run -- <cmd>\" instead\n"))
7175
err = box.Exec(cmds...)
7276
} else {
7377
err = box.Shell()

0 commit comments

Comments
 (0)