Files
whatshooked/cmd/cli/main.go
Hein 500db67c72
Some checks failed
CI / Build (push) Failing after -22m48s
CI / Lint (push) Failing after -22m29s
CI / Test (1.23) (push) Failing after -22m10s
CI / Test (1.22) (push) Failing after -22m17s
feat(cli): add user management commands for CRUD operations
2026-02-20 20:48:57 +02:00

48 lines
1.1 KiB
Go

package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
var (
cfgFile string
serverURL string
cliConfig *CLIConfig
)
func main() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
var rootCmd = &cobra.Command{
Use: "whatshook-cli",
Short: "WhatsHooked CLI - Manage WhatsApp webhooks",
Long: `A command-line interface for managing WhatsHooked server, hooks, and WhatsApp accounts.`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
var err error
cliConfig, err = LoadCLIConfig(cfgFile, serverURL)
if err != nil {
fmt.Fprintf(os.Stderr, "Error loading config: %v\n", err)
os.Exit(1)
}
},
}
func init() {
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default: $HOME/.whatshooked/cli.json)")
rootCmd.PersistentFlags().StringVar(&serverURL, "server", "", "server URL (default: http://localhost:8825)")
// Add all command groups
rootCmd.AddCommand(healthCmd)
rootCmd.AddCommand(hooksCmd)
rootCmd.AddCommand(accountsCmd)
rootCmd.AddCommand(sendCmd)
rootCmd.AddCommand(usersCmd)
}