cmd

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RootCmd = &cobra.Command{
		Use:     "infraspec [features...]",
		Short:   "InfraSpec tests infrastructure code in plain English.",
		Long:    `InfraSpec is a tool for testing your cloud infrastructure in plain English, no code required.`,
		Version: build.Version,
		Args:    cobra.MinimumNArgs(1),
		Run: func(cmd *cobra.Command, args []string) {
			startTime := time.Now()

			cfg, err := config.LoadConfig("", virtualCloud)
			if err != nil {
				fmt.Printf("Failed to load config: %v\n", err)
				return
			}

			if parallel > 0 {
				cfg.ParallelMode = true
			}

			if verbose {
				cfg.Verbose = true
				config.Logging.Logger.Debug("Verbose mode enabled")
			}

			if err := awshelpers.CheckVirtualCloudHealth(); err != nil {
				fmt.Printf("Virtual Cloud health check failed: %v\n", err)
				return
			}

			tel := telemetry.New(telemetry.Config{
				Enabled: cfg.Telemetry.Enabled,
				UserID:  cfg.Telemetry.UserID,
				Logger:  zap.NewNop().Sugar(),
			})

			defer tel.Flush()

			tel.TrackCLIStart(args)
			tel.TrackConfigLoaded("default")

			// Discover all feature files from provided paths
			var featureFiles []string
			for _, arg := range args {
				files, err := runner.DiscoverFeatureFiles(arg)
				if err != nil {
					log.Fatalf("Failed to discover features: %v", err)
				}
				featureFiles = append(featureFiles, files...)
			}

			featureFiles = runner.UniqueStrings(featureFiles)

			if parallel > 0 && len(featureFiles) > 1 {

				runParallel(cfg, tel, featureFiles, startTime)
			} else {

				runSequential(cfg, tel, featureFiles, startTime)
			}
		},
	}
)

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL