Skip to content

Commit 30eda19

Browse files
authored
Update devbox run help text (#517)
## Summary Update help text when unified env feature is on. This feature also enables `run` to accept arbitrary commands, and to pass arguments to scripts. ## How was it tested? ``` > DEVBOX_FEATURE_UNIFIED_ENV=1 ./devbox run --help Starts a new shell and runs your script or command in it, exiting when done. The script must be defined in `devbox.json`, or else it will be interpreted as an arbitrary command. You can pass arguments to your script or command. Everything after `--` will be passed verbatim into your command (see examples). Usage: devbox run [<script> | <cmd>] [flags] Examples: Run a command directly: devbox add cowsay devbox run cowsay hello devbox run -- cowsay -d hello Run a script (defined as `"moo": "cowsay moo"`) in your devbox.json: devbox run moo Flags: -c, --config string path to directory containing a devbox.json config file -h, --help help for run Global Flags: -q, --quiet suppresses logs. ```
1 parent 22b5b48 commit 30eda19

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

internal/boxcli/run.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package boxcli
55

66
import (
77
"github.com/pkg/errors"
8+
"github.com/samber/lo"
89
"github.com/spf13/cobra"
910
"go.jetpack.io/devbox"
1011
"go.jetpack.io/devbox/internal/boxcli/featureflag"
@@ -17,11 +18,27 @@ type runCmdFlags struct {
1718
}
1819

1920
func RunCmd() *cobra.Command {
21+
longHelp := "Starts a new shell and runs your script or command in it, exiting when done.\n\n" +
22+
"The script must be defined in `devbox.json`, or else it will be interpreted as an " +
23+
"arbitrary command. You can pass arguments to your script or command. Everything " +
24+
"after `--` will be passed verbatim into your command (see examples).\n\n"
25+
shortHelp := "Runs a script or command in a shell with access to your packages"
26+
example := "\nRun a command directly:\n\n devbox add cowsay\n devbox run cowsay hello\n " +
27+
"devbox run -- cowsay -d hello\n\nRun a script (defined as `\"moo\": \"cowsay moo\"`) " +
28+
"in your devbox.json:\n\n devbox run moo"
29+
if featureflag.UnifiedEnv.Disabled() {
30+
shortHelp = "Starts a new devbox shell and runs the target script"
31+
longHelp = "Starts a new interactive shell and runs your target script in it. The shell will " +
32+
"exit once your target script is completed or when it is terminated via CTRL-C. " +
33+
"Scripts can be defined in your `devbox.json`"
34+
example = ""
35+
}
2036
flags := runCmdFlags{}
2137
command := &cobra.Command{
22-
Use: "run <script>",
23-
Short: "Starts a new devbox shell and runs the target script",
24-
Long: "Starts a new interactive shell and runs your target script in it. The shell will exit once your target script is completed or when it is terminated via CTRL-C. Scripts can be defined in your `devbox.json`",
38+
Use: lo.Ternary(featureflag.UnifiedEnv.Enabled(), "run [<script> | <cmd>]", "run <script>"),
39+
Short: shortHelp,
40+
Long: longHelp,
41+
Example: example,
2542
Args: cobra.MinimumNArgs(1),
2643
PreRunE: ensureNixInstalled,
2744
RunE: func(cmd *cobra.Command, args []string) error {

0 commit comments

Comments
 (0)