eclipse/cmd/eclipse-keygen/main.go

57 lines
1.3 KiB
Go
Raw Normal View History

2024-01-18 07:48:14 +00:00
// 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 {
2024-01-18 19:08:10 +00:00
// TODO: generate leader keys
2024-01-18 07:48:14 +00:00
return nil
},
})
argparser.AddCommand(&cobra.Command{
Use: "follower [flags]",
Args: cliutil.WrapPositionalArgs(cobra.NoArgs),
RunE: func(*cobra.Command, []string) error {
2024-01-18 19:08:10 +00:00
// TODO: generate follower key
2024-01-18 07:48:14 +00:00
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)
}
}