@@ -4,43 +4,14 @@ package main
44import (
55 "os"
66
7- "github.com/canonical/authd/cmd/authctl/group"
87 "github.com/canonical/authd/cmd/authctl/internal/log"
9- "github.com/canonical/authd/cmd/authctl/user"
10- "github.com/spf13/cobra"
8+ "github.com/canonical/authd/cmd/authctl/root"
119 "google.golang.org/grpc/codes"
1210 "google.golang.org/grpc/status"
1311)
1412
15- var rootCmd = & cobra.Command {
16- Use : "authctl" ,
17- Short : "CLI tool to interact with authd" ,
18- Long : "authctl is a command-line tool to interact with the authd service for user and group management." ,
19- PersistentPreRun : func (cmd * cobra.Command , args []string ) {
20- // The command was successfully parsed, so we don't want cobra to print usage information on error.
21- cmd .SilenceUsage = true
22- },
23- CompletionOptions : cobra.CompletionOptions {
24- HiddenDefaultCmd : true ,
25- },
26- // We handle errors ourselves
27- SilenceErrors : true ,
28- Args : cobra .NoArgs ,
29- RunE : func (cmd * cobra.Command , args []string ) error { return cmd .Usage () },
30- }
31-
32- func init () {
33- // Disable command sorting by name. This makes cobra print the commands in the
34- // order they are added to the root command and adds the `help` and `completion`
35- // commands at the end.
36- cobra .EnableCommandSorting = false
37-
38- rootCmd .AddCommand (user .UserCmd )
39- rootCmd .AddCommand (group .GroupCmd )
40- }
41-
4213func main () {
43- if err := rootCmd .Execute (); err != nil {
14+ if err := root . RootCmd .Execute (); err != nil {
4415 s , ok := status .FromError (err )
4516 if ! ok {
4617 // If the error is not a gRPC status, we print it as is.
0 commit comments