// Copyright (C) 2023-2024 Umorpha Systems // SPDX-License-Identifier: AGPL-3.0-or-later package main import ( "context" "fmt" "os" "github.com/datawire/ocibuild/pkg/cliutil" "github.com/spf13/cobra" ) func main() { argparser := &cobra.Command{ Use: os.Args[0] + " {[flags]|SUBCOMMAND...}", Short: "Generate API keys", Args: cliutil.WrapPositionalArgs(cliutil.OnlySubcommands), RunE: cliutil.RunSubcommands, SilenceErrors: true, // we'll handle this ourselves after .ExecuteContext() SilenceUsage: true, // FlagErrorFunc will handle this CompletionOptions: cobra.CompletionOptions{ DisableDefaultCmd: true, }, } argparser.SetFlagErrorFunc(cliutil.FlagErrorFunc) argparser.SetHelpTemplate(cliutil.HelpTemplate) argparser.AddCommand(&cobra.Command{ Use: "leader [flags]", Args: cliutil.WrapPositionalArgs(cobra.NoArgs), RunE: func(*cobra.Command, []string) error { // TODO return nil }, }) argparser.AddCommand(&cobra.Command{ Use: "follower [flags]", Args: cliutil.WrapPositionalArgs(cobra.NoArgs), RunE: func(*cobra.Command, []string) error { // TODO return nil }, }) ctx := context.Background() if err := argparser.ExecuteContext(ctx); err != nil { fmt.Fprintf(os.Stderr, "%v: error: %v\n", argparser.CommandPath(), err) os.Exit(1) } }