github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/e2e/cli-plugins/plugins/nopersistentprerun/main.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/khulnasoft/cli/cli-plugins/manager"
     7  	"github.com/khulnasoft/cli/cli-plugins/plugin"
     8  	"github.com/khulnasoft/cli/cli/command"
     9  	"github.com/spf13/cobra"
    10  )
    11  
    12  func main() {
    13  	plugin.Run(func(dockerCli command.Cli) *cobra.Command {
    14  		cmd := &cobra.Command{
    15  			Use:   "nopersistentprerun",
    16  			Short: "Testing without PersistentPreRun hooks",
    17  			// PersistentPreRunE: Not specified, we need to test that it works in the absence of an explicit call
    18  			RunE: func(cmd *cobra.Command, args []string) error {
    19  				cli := dockerCli.Client()
    20  				ping, err := cli.Ping(cmd.Context())
    21  				if err != nil {
    22  					return err
    23  				}
    24  				fmt.Println(ping.APIVersion)
    25  				return nil
    26  			},
    27  		}
    28  		return cmd
    29  	},
    30  		manager.Metadata{
    31  			SchemaVersion: "0.1.0",
    32  			Vendor:        "Docker Inc.",
    33  			Version:       "testing",
    34  		})
    35  }