mirror of
https://github.com/Squibid/rph.git
synced 2025-10-20 03:44:04 +00:00
- Add vendordep add - Add vendordep remove - Add vendordep list - Refactor downloading
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
package cmd
|
|
|
|
import (
|
|
"log/slog"
|
|
"rph/cmd/vendordep"
|
|
"strings"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func vendorDepsComp(cmd *cobra.Command, args []string, toComplete string) ([]cobra.Completion, cobra.ShellCompDirective) {
|
|
validVendordeps, err := vendordep.ListVendorDeps(projectFs)
|
|
if err != nil {
|
|
slog.Error("Unable to find vendor deps", "error", err)
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
}
|
|
|
|
var completions []string
|
|
for _, dep := range validVendordeps {
|
|
if strings.HasPrefix(dep.Name, toComplete) {
|
|
completions = append(completions, dep.Name)
|
|
}
|
|
}
|
|
|
|
return completions, cobra.ShellCompDirectiveNoFileComp
|
|
}
|
|
|
|
// vendordepCmd represents the vendordep command
|
|
var vendordepCmd = &cobra.Command{
|
|
Use: "vendordep",
|
|
Aliases: []string{ "vend" },
|
|
Short: "Mange your WPILIB projects vendordeps",
|
|
Long: `Mange your WPILIB projects vendordeps`,
|
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
|
superPersistentPreRun(cmd, args)
|
|
vendordep.MkCacheDir()
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(vendordepCmd)
|
|
}
|