38 lines
835 B
Go
38 lines
835 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
flagHost string
|
|
flagPort int
|
|
)
|
|
|
|
func init() {
|
|
// define global CLI flags
|
|
rootCmd.PersistentFlags().StringVarP(&flagHost, "host", "H", "ldap.example.com", "LDAP host to perform operations on")
|
|
rootCmd.PersistentFlags().IntVarP(&flagPort, "port", "p", 389, "TCP port that the LDAP host is listening on")
|
|
}
|
|
|
|
// define root command
|
|
var rootCmd = &cobra.Command{
|
|
Use: "muldap",
|
|
Short: "muldap is Metaunix.net's LDAP management tool",
|
|
Long: "LDAP management tool for Metaunix.net user and group resources.",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
fmt.Println("Metaunix.net LDAP tool - available commands are: search, version")
|
|
},
|
|
}
|
|
|
|
// start CLI app
|
|
func Execute() {
|
|
if err := rootCmd.Execute(); err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
}
|