github.com/vchain-us/vcn@v0.9.11-0.20210921212052-a2484d23c0b3/pkg/cmd/sign/flags.go (about)

     1  /*
     2   * Copyright (c) 2018-2020 vChain, Inc. All Rights Reserved.
     3   * This software is released under GPL3.
     4   * The full license information can be found under:
     5   * https://www.gnu.org/licenses/gpl-3.0.en.html
     6   *
     7   */
     8  
     9  package sign
    10  
    11  import (
    12  	"fmt"
    13  
    14  	"github.com/spf13/cobra"
    15  )
    16  
    17  func noArgsWhenHashOrPipe(cmd *cobra.Command, args []string) error {
    18  	if hash, _ := cmd.Flags().GetString("hash"); hash != "" {
    19  		if len(args) > 0 {
    20  			return fmt.Errorf("cannot use ARG(s) with --hash")
    21  		}
    22  		return nil
    23  	}
    24  	if pipeMode() {
    25  		return nil
    26  	}
    27  	return cobra.ExactArgs(1)(cmd, args)
    28  }