github.com/olli-ai/jx/v2@v2.0.400-0.20210921045218-14731b4dd448/pkg/cmd/scan.go (about)

     1  package cmd
     2  
     3  import (
     4  	"github.com/olli-ai/jx/v2/pkg/cmd/helper"
     5  	"github.com/olli-ai/jx/v2/pkg/cmd/opts"
     6  	"github.com/olli-ai/jx/v2/pkg/cmd/templates"
     7  	"github.com/spf13/cobra"
     8  )
     9  
    10  // Scan Options contains the command line options for scan commands
    11  type ScanOptions struct {
    12  	*opts.CommonOptions
    13  }
    14  
    15  var (
    16  	scan_long = templates.LongDesc(`
    17  		Perform a scan action.
    18  	`)
    19  )
    20  
    21  // NewCmdScan creates a command object for the "scan" command
    22  func NewCmdScan(commonOpts *opts.CommonOptions) *cobra.Command {
    23  	options := &ScanOptions{
    24  		CommonOptions: commonOpts,
    25  	}
    26  
    27  	cmd := &cobra.Command{
    28  		Use:   "scan",
    29  		Short: "Perform a scan action",
    30  		Long:  scan_long,
    31  		Run: func(cmd *cobra.Command, args []string) {
    32  			options.Cmd = cmd
    33  			options.Args = args
    34  			err := options.Run()
    35  			helper.CheckErr(err)
    36  		},
    37  	}
    38  
    39  	cmd.AddCommand(NewCmdScanCluster(commonOpts))
    40  
    41  	return cmd
    42  }
    43  
    44  // Run executes the scan commands
    45  func (o *ScanOptions) Run() error {
    46  	return o.Cmd.Help()
    47  }