-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathroot.go
More file actions
38 lines (34 loc) · 1.27 KB
/
root.go
File metadata and controls
38 lines (34 loc) · 1.27 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
// Package root contains the root command for authctl.
package root
import (
"github.com/canonical/authd/cmd/authctl/group"
"github.com/canonical/authd/cmd/authctl/user"
"github.com/spf13/cobra"
)
// RootCmd is the root command for authctl.
var RootCmd = &cobra.Command{
Use: "authctl",
Short: "CLI tool to interact with authd",
Long: "authctl is a command-line tool to interact with the authd service for user and group management.",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
// The command was successfully parsed, so we don't want cobra to print usage information on error.
cmd.SilenceUsage = true
},
CompletionOptions: cobra.CompletionOptions{
HiddenDefaultCmd: true,
},
// Avoid the "Auto generated by spf13/cobra" line in the generated markdown docs
DisableAutoGenTag: true,
// We handle errors ourselves
SilenceErrors: true,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { return cmd.Usage() },
}
func init() {
// Disable command sorting by name. This makes cobra print the commands in the
// order they are added to the root command and adds the `help` and `completion`
// commands at the end.
cobra.EnableCommandSorting = false
RootCmd.AddCommand(user.UserCmd)
RootCmd.AddCommand(group.GroupCmd)
}