func NewParseCommand(ctx context.Context) *cobra.Command {
	cmd := cobra.Command{
		Use:   "parse [file...]",
		Short: "Print out structured data from your input files",
		Long:  parseDesc,
		PreRunE: func(cmd *cobra.Command, args []string) error {
			flagNames := []string{"input", "combine"}
			for _, name := range flagNames {
				if err := viper.BindPFlag(name, cmd.Flags().Lookup(name)); err != nil {
					return fmt.Errorf("bind flag: %w", err)
				}
			}

			return nil
		},
		RunE: func(cmd *cobra.Command, fileList []string) error {
			out, err := parseInput(ctx, viper.GetString("input"), viper.GetBool("combine"), fileList)
			if err != nil {
				return fmt.Errorf("failed during parser process: %w", err)
			}

			fmt.Println(out)
			return nil
		},
	}

	cmd.Flags().BoolP("combine", "", false, "combine all given config files to be evaluated together")
	cmd.Flags().StringP("input", "i", "", fmt.Sprintf("input type for given source, especially useful when using conftest with stdin, valid options are: %s", parser.ValidInputs()))
	return &cmd
}
// NewParseCommand creates a parse command.
// This command can be used for printing structured inputs from unstructured configuration inputs.
NewParseCommand creates a parse command.
This command can be used for printing structured inputs from unstructured configuration inputs.
// NewParseCommand creates a parse command . // This command can be used for printing structured inputs from unstructured configuration inputs .
func NewParseCommand(ctx context.Context) *cobra.Command {
	cmd := cobra.Command{
		Use:   "parse [file...]",
		Short: "Print out structured data from your input files",
		Long:  parseDesc,
		PreRunE: func(cmd *cobra.Command, args []string) error {
			flagNames := []string{"input", "combine"}
			for _, name := range flagNames {
				if err := viper.BindPFlag(name, cmd.Flags().Lookup(name)); err != nil {
					return fmt.Errorf("bind flag: %w", err)
				}
			}
			return nil
		},
		RunE: func(cmd *cobra.Command, fileList []string) error {
			out, err := parseInput(ctx, viper.GetString("input"), viper.GetBool("combine"), fileList)
			if err != nil {
				return fmt.Errorf("failed during parser process: %w", err)
			}
			fmt.Println(out)
			return nil
		},
	}
	cmd.Flags().BoolP("combine", "", false, "combine all given config files to be evaluated together")
	cmd.Flags().StringP("input", "i", "", fmt.Sprintf("input type for given source, especially useful when using conftest with stdin, valid options are: %s", parser.ValidInputs()))
	return &cmd
}
func NewParseCommand ( ctx context . Context ) * cobra . Command { cmd := cobra . Command { Use : " " , Short : " " , Long : parseDesc , PreRunE : func ( cmd * cobra . Command , args [ ] string ) error { flagNames := [ ] string { " " , " " } for _ , name := range flagNames { if err := viper . BindPFlag ( name , cmd . Flags ( ) . Lookup ( name ) ) ; err != nil { return fmt . Errorf ( " " , err ) } } return nil } , RunE : func ( cmd * cobra . Command , fileList [ ] string ) error { out , err := parseInput ( ctx , viper . GetString ( " " ) , viper . GetBool ( " " ) , fileList ) if err != nil { return fmt . Errorf ( " " , err ) } fmt . Println ( out ) return nil } , } cmd . Flags ( ) . BoolP ( " " , " " , false , " " ) cmd . Flags ( ) . StringP ( " " , " " , " " , fmt . Sprintf ( " " , parser . ValidInputs ( ) ) ) return & cmd }
NewParseCommand creates a parse command.
NewParseCommand creates a parse command .