Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/boxcli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func RootCmd() *cobra.Command {
command.AddCommand(globalCmd())
command.AddCommand(InfoCmd())
command.AddCommand(InitCmd())
command.AddCommand(InstallCmd())
command.AddCommand(LogCmd())
command.AddCommand(PlanCmd())
command.AddCommand(RemoveCmd())
Expand Down
28 changes: 28 additions & 0 deletions internal/boxcli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package boxcli

import (
"fmt"

"github.com/pkg/errors"
"github.com/spf13/cobra"
"go.jetpack.io/devbox"
Expand Down Expand Up @@ -41,6 +43,32 @@ func RunCmd() *cobra.Command {
return command
}

func InstallCmd() *cobra.Command {
flags := runCmdFlags{}
command := &cobra.Command{
Use: "install",
Short: "Installs all packages mentioned in devbox.json",
Long: "Starts a new devbox shell and installs all packages mentioned in devbox.json in current directory or" +
"a directory specified via --config. \n\n Then exits the shell when packages are done installing.\n\n ",
Args: cobra.MaximumNArgs(0),
PreRunE: ensureNixInstalled,
RunE: func(cmd *cobra.Command, args []string) error {
// the colon ':' character in standard shell means noop.
// So essentially, this command is running devbox run noop
err := runScriptCmd(cmd, []string{":"}, flags)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for shell n00bs like myself, would you mind adding a small comment explaining that : is a noop in shell?

if err != nil {
return err
}
fmt.Fprintln(cmd.ErrOrStderr(), "Finished installing packages.")
return nil
},
}

flags.config.register(command)

return command
}

func listScripts(cmd *cobra.Command, flags runCmdFlags) []string {
path, err := configPathFromUser([]string{}, &flags.config)
if err != nil {
Expand Down