Skip to content
Draft
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
21 changes: 19 additions & 2 deletions box/hidden_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ func runHiddenCliAndExitIfCalled(b *Box, packageVersion, packageConstraintsUrl s
},
}

var installCmd = &cobra.Command{
Use: "install",
Short: "Ensure the package is installed with the latest version",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
if yes, err := b.NeedsInstall(); err != nil {
logger.Fatal("Failed to check if box needs install", logger.Args("error", err))
} else if yes {
logger.Trace("Installing box")
if err := b.InstallWithSpinner(); err != nil {
logger.Fatal("Failed to install box", logger.Args("error", err))
}
}
},
}

var updateCmd = &cobra.Command{
Use: "update",
Short: "Update the package to the latest available version",
Expand Down Expand Up @@ -114,10 +130,11 @@ func runHiddenCliAndExitIfCalled(b *Box, packageVersion, packageConstraintsUrl s
}

cacheCmd.AddCommand(cleanCacheCmd)
selfCmd.AddCommand(installCmd)
selfCmd.AddCommand(updateCmd)
selfCmd.AddCommand(removeCmd)
selfCmd.AddCommand(cacheCmd)
selfCmd.AddCommand(pathCmd)
selfCmd.AddCommand(removeCmd)
selfCmd.AddCommand(updateCmd)
selfCmd.AddCommand(uvCmd)
rootCmd.AddCommand(selfCmd)

Expand Down