-
-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathroot.go
More file actions
57 lines (48 loc) · 1.9 KB
/
root.go
File metadata and controls
57 lines (48 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/pnpm"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "pnpm",
Short: "Fast, disk space efficient package manager",
Long: "https://pnpm.io/",
Run: func(cmd *cobra.Command, args []string) {},
}
func Execute() error {
return rootCmd.Execute()
}
func init() {
carapace.Gen(rootCmd).Standalone()
rootCmd.AddGroup(
&cobra.Group{ID: "manage", Title: "Manage Commands"},
&cobra.Group{ID: "review", Title: "Review Commands"},
&cobra.Group{ID: "run", Title: "Run Commands"},
&cobra.Group{ID: "store", Title: "Store Commands"},
&cobra.Group{ID: "other", Title: "Other Commands"},
)
rootCmd.Flags().BoolP("help", "h", false, "show help")
rootCmd.Flags().BoolP("recursive", "r", false, "Run the command for each project in the workspace")
rootCmd.Flags().BoolP("version", "v", false, "show version")
rootCmd.Flags().String("filter", "", "set filter")
rootCmd.Flags().String("filter-prod", "", "Restricts the scope to package names matching the given pattern")
rootCmd.Flags().String("loglevel", "", "What level of logs to report")
rootCmd.Flags().Bool("color", false, "Controls colors in the output")
rootCmd.Flags().Bool("no-color", false, "Controls colors in the output")
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"filter": pnpm.ActionFilter(),
"filter-prod": pnpm.ActionFilter(),
"loglevel": pnpm.ActionLoglevel(),
})
}
func addWorkspaceFlags(cmd *cobra.Command) {
cmd.Flags().StringArrayP("workspace", "w", []string{""}, "Enable running a command in the context of the given workspace")
cmd.Flags().Bool("workspaces", false, "Enable running a command in the context of all workspaces")
carapace.Gen(cmd).FlagCompletion(carapace.ActionMap{
"workspace": carapace.Batch(
pnpm.ActionWorkspaces(),
pnpm.ActionWorkspaceDependencies(),
).ToA(),
})
}