github.com/henvic/wedeploycli@v1.7.6-0.20200319005353-3630f582f284/command/about/legal/legal.go (about)

     1  package legal
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"os/exec"
     7  	"strings"
     8  
     9  	"github.com/henvic/wedeploycli/legal"
    10  	"github.com/henvic/wedeploycli/verbose"
    11  	"github.com/spf13/cobra"
    12  )
    13  
    14  // LegalCmd is used for showing the abouts of all used libraries
    15  var LegalCmd = &cobra.Command{
    16  	Use:   "legal",
    17  	RunE:  legalRun,
    18  	Args:  cobra.NoArgs,
    19  	Short: "Legal notices",
    20  }
    21  
    22  func legalRun(cmd *cobra.Command, args []string) error {
    23  	pager := exec.Command("less") // #nosec
    24  	pager.Stdin = strings.NewReader(getLegalNotices())
    25  	pager.Stdout = os.Stdout
    26  	err := pager.Run()
    27  
    28  	if err != nil {
    29  		verbose.Debug("can't page with less: " + err.Error())
    30  		fmt.Print(getLegalNotices())
    31  	}
    32  
    33  	return nil
    34  }
    35  
    36  func getLegalNotices() string {
    37  	return fmt.Sprintf(`Legal Notices:
    38  
    39  Copyright © 2016-present Liferay, Inc.
    40  Liferay Cloud Platform CLI Software License Agreement
    41  
    42  Liferay, the Liferay logo, WeDeploy, and WeDeploy logo
    43  are trademarks of Liferay, Inc., registered in the U.S. and other countries.
    44  
    45  Acknowledgements:
    46  Portions of this Liferay software may utilize the following copyrighted material,
    47  the use of which is hereby acknowledged.
    48  
    49  %s`, legal.Licenses)
    50  }