github.com/drycc/workflow-cli@v1.5.3-0.20240322092846-d4ee25983af9/cmd/version.go (about)

     1  package cmd
     2  
     3  import (
     4  	drycc "github.com/drycc/controller-sdk-go"
     5  	"github.com/drycc/workflow-cli/settings"
     6  	"github.com/drycc/workflow-cli/version"
     7  )
     8  
     9  // Version prints the various CLI versions.
    10  func (d *DryccCmd) Version(all bool) error {
    11  	if !all {
    12  		d.Println(version.Version)
    13  		return nil
    14  	}
    15  
    16  	d.Printf("Workflow CLI Version:            %s\n", version.Version)
    17  	d.Printf("Workflow CLI API Version:        %s\n", drycc.APIVersion)
    18  
    19  	s, err := settings.Load(d.ConfigFile)
    20  
    21  	if err != nil {
    22  		return err
    23  	}
    24  
    25  	// retrieve version information from drycc controller
    26  	err = s.Client.Healthcheck()
    27  
    28  	if err != nil && err != drycc.ErrAPIMismatch {
    29  		return err
    30  	}
    31  
    32  	d.Printf("Workflow Controller API Version: %s\n", s.Client.ControllerAPIVersion)
    33  	return nil
    34  }