github.com/naphatkrit/deis@v1.12.3/client/parser/utils.go (about)

     1  package parser
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"strconv"
     7  )
     8  
     9  func safeGetValue(args map[string]interface{}, key string) string {
    10  	if args[key] == nil {
    11  		return ""
    12  	}
    13  	return args[key].(string)
    14  }
    15  
    16  func responseLimit(limit string) (int, error) {
    17  	if limit == "" {
    18  		return -1, nil
    19  	}
    20  
    21  	return strconv.Atoi(limit)
    22  }
    23  
    24  // PrintUsage runs if no matching command is found.
    25  func PrintUsage() {
    26  	fmt.Fprintln(os.Stderr, "Found no matching command, try 'deis help'")
    27  	fmt.Fprintln(os.Stderr, "Usage: deis <command> [<args>...]")
    28  }
    29  
    30  func printHelp(argv []string, usage string) bool {
    31  	if len(argv) > 1 {
    32  		if argv[1] == "--help" || argv[1] == "-h" {
    33  			fmt.Print(usage)
    34  			return true
    35  		}
    36  	}
    37  
    38  	return false
    39  }