OpenSlides/performance/cmd/root.go

57 lines
1.3 KiB
Go
Raw Normal View History

2021-02-25 08:40:04 +01:00
package cmd
import (
"github.com/spf13/cobra"
)
const rootHelp = `Performance is an helper tool to test the limits of OpenSlies.
Each task is implemented as a subcommand.`
type config struct {
domain string
username string
password string
2021-05-07 15:43:43 +02:00
http bool
}
func (c *config) addr() string {
proto := "https"
if c.http {
proto = "http"
}
return proto + "://" + c.domain
2021-02-25 08:40:04 +01:00
}
func cmdRoot(cfg *config) *cobra.Command {
cmd := &cobra.Command{
2021-05-07 15:43:43 +02:00
Use: "performance",
Short: "performance is a tool that brings OpenSlides to its limit.",
Long: rootHelp,
SilenceUsage: true,
2021-02-25 08:40:04 +01:00
}
cmd.PersistentFlags().StringVarP(&cfg.domain, "domain", "d", "localhost:8000", "Domain where to send the requests")
cmd.PersistentFlags().StringVarP(&cfg.username, "username", "u", "admin", "Username that can create the users.")
cmd.PersistentFlags().StringVarP(&cfg.password, "password", "p", "admin", "Password to use.")
2021-05-07 15:43:43 +02:00
cmd.PersistentFlags().BoolVar(&cfg.http, "http", false, "Use http instead of https. Default is https.")
2021-02-25 08:40:04 +01:00
return cmd
}
// Execute starts the root command.
func Execute() error {
cfg := new(config)
cmd := cmdRoot(cfg)
cmd.AddCommand(
cmdBrowser(cfg),
cmdConnect(cfg),
cmdCreateUsers(cfg),
cmdVotes(cfg),
cmdCreateAmendments(cfg),
2021-05-07 15:43:43 +02:00
cmdCreateCandidates(cfg),
2021-02-25 08:40:04 +01:00
)
return cmd.Execute()
}