2023-08-31 08:35:53 +00:00
|
|
|
package modules
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"runtime"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"git.frostfs.info/TrueCloudLab/s3-tests-parser/internal/version"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
|
|
|
// rootCmd represents the base command when called without any subcommands.
|
|
|
|
var rootCmd = &cobra.Command{
|
|
|
|
Use: "s3-tests-parser",
|
|
|
|
Version: version.Version,
|
|
|
|
Short: "FrostFS S3 Tests Parser",
|
|
|
|
Long: "Helps manage s3 compatibility test results",
|
|
|
|
Example: "s3-tests-parser --version",
|
|
|
|
SilenceErrors: true,
|
|
|
|
SilenceUsage: true,
|
|
|
|
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
|
|
|
|
viper.AutomaticEnv()
|
|
|
|
viper.SetEnvPrefix("S3_TESTS_PARSER")
|
|
|
|
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
|
|
|
viper.AllowEmptyEnv(true)
|
|
|
|
|
|
|
|
return viper.BindPFlags(cmd.Flags())
|
|
|
|
},
|
|
|
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
|
|
|
return cmd.Help()
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func Execute(ctx context.Context) (*cobra.Command, error) {
|
|
|
|
return rootCmd.ExecuteContextC(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cobra.AddTemplateFunc("runtimeVersion", runtime.Version)
|
|
|
|
rootCmd.SetVersionTemplate(`Frostfs S3 Tests Parser
|
|
|
|
{{printf "Version: %s" .Version }}
|
|
|
|
GoVersion: {{ runtimeVersion }}
|
|
|
|
`)
|
|
|
|
|
|
|
|
rootCmd.AddCommand(compatibilityCmd)
|
|
|
|
initCompatibilityCmd()
|
2024-11-22 08:49:26 +00:00
|
|
|
|
|
|
|
rootCmd.AddCommand(testsCmd)
|
|
|
|
initTestsCmd()
|
2023-08-31 08:35:53 +00:00
|
|
|
}
|