github.com/iaas-resource-provision/iaas-rpc@v1.0.7-0.20211021023331-ed21f798c408/internal/command/hook_module_install.go (about)

     1  package command
     2  
     3  import (
     4  	"fmt"
     5  
     6  	version "github.com/hashicorp/go-version"
     7  	"github.com/iaas-resource-provision/iaas-rpc/internal/initwd"
     8  	"github.com/mitchellh/cli"
     9  )
    10  
    11  type uiModuleInstallHooks struct {
    12  	initwd.ModuleInstallHooksImpl
    13  	Ui             cli.Ui
    14  	ShowLocalPaths bool
    15  }
    16  
    17  var _ initwd.ModuleInstallHooks = uiModuleInstallHooks{}
    18  
    19  func (h uiModuleInstallHooks) Download(modulePath, packageAddr string, v *version.Version) {
    20  	if v != nil {
    21  		h.Ui.Info(fmt.Sprintf("Downloading %s %s for %s...", packageAddr, v, modulePath))
    22  	} else {
    23  		h.Ui.Info(fmt.Sprintf("Downloading %s for %s...", packageAddr, modulePath))
    24  	}
    25  }
    26  
    27  func (h uiModuleInstallHooks) Install(modulePath string, v *version.Version, localDir string) {
    28  	if h.ShowLocalPaths {
    29  		h.Ui.Info(fmt.Sprintf("- %s in %s", modulePath, localDir))
    30  	} else {
    31  		h.Ui.Info(fmt.Sprintf("- %s", modulePath))
    32  	}
    33  }