You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First pass at devbox scripts implementation (#254)
## Summary
Devbox scripts allows you to define scripts to run inside a devbox
shell. You can add them to your devbox.json like so:
```
{
"packages": [],
"shell": {
"init_hook": "echo hook",
"scripts": {
"a": "echo hello",
"b": [
"echo good",
"echo bye"
]
}
}
}
```
And then you can run with `devbox run <script>`. For example:
```
> devbox run b
Installing nix packages. This may take a while... done.
Starting a devbox shell...
hook
good
bye
```
Note that the shell's init hook will always run.
## How was it tested?
With a devbox.json as written above and running `devbox run <script>`
with no script, invalid script, valid script (single command and
multi-command).
Co-authored-by: John Lago <[email protected]>
// Copyright 2022 Jetpack Technologies Inc and contributors. All rights reserved.
2
+
// Use of this source code is governed by the license in the LICENSE file.
3
+
4
+
package boxcli
5
+
6
+
import (
7
+
"os"
8
+
"os/exec"
9
+
"sort"
10
+
11
+
"github.com/pkg/errors"
12
+
"github.com/spf13/cobra"
13
+
"go.jetpack.io/devbox"
14
+
"golang.org/x/exp/slices"
15
+
)
16
+
17
+
typerunCmdFlagsstruct {
18
+
configconfigFlags
19
+
}
20
+
21
+
funcRunCmd() *cobra.Command {
22
+
flags:=runCmdFlags{}
23
+
command:=&cobra.Command{
24
+
Use: "run <script>",
25
+
Hidden: true,
26
+
Short: "Starts a new devbox shell and runs the target script",
27
+
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`",
0 commit comments