Skip to content

Commit e3bf74d

Browse files
authored
[run] Add list flag to list all scripts (#1167)
## Summary Add `list` flag to `devbox run` to list all scripts. ## How was it tested? `devbox run --list` `devbox run -l`
1 parent 29bc467 commit e3bf74d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

internal/boxcli/run.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ import (
1616
)
1717

1818
type runCmdFlags struct {
19-
config configFlags
20-
pure bool
19+
config configFlags
20+
pure bool
21+
listScripts bool
2122
}
2223

2324
func runCmd() *cobra.Command {
@@ -41,6 +42,8 @@ func runCmd() *cobra.Command {
4142
flags.config.register(command)
4243
command.Flags().BoolVar(
4344
&flags.pure, "pure", false, "If this flag is specified, devbox runs the script in an isolated environment inheriting almost no variables from the current environment. A few variables, in particular HOME, USER and DISPLAY, are retained.")
45+
command.Flags().BoolVarP(
46+
&flags.listScripts, "list", "l", false, "List all scripts defined in devbox.json")
4447

4548
command.ValidArgs = listScripts(command, flags)
4649

@@ -63,7 +66,7 @@ func listScripts(cmd *cobra.Command, flags runCmdFlags) []string {
6366
}
6467

6568
func runScriptCmd(cmd *cobra.Command, args []string, flags runCmdFlags) error {
66-
if len(args) == 0 {
69+
if len(args) == 0 || flags.listScripts {
6770
scripts := listScripts(cmd, flags)
6871
if len(scripts) == 0 {
6972
fmt.Fprintln(cmd.OutOrStdout(), "no scripts defined in devbox.json")

0 commit comments

Comments
 (0)