github.com/ernestokarim/closurer@v0.0.0-20130119214741-f245d086c750/config/flags.go (about)

     1  package config
     2  
     3  import (
     4  	"flag"
     5  	"strings"
     6  )
     7  
     8  var (
     9  	// Command line flags
    10  	Build, NoCache, OutputCmd    bool
    11  	Port, ConfPath, BuildTargets string
    12  )
    13  
    14  var (
    15  	SelectedTarget string
    16  )
    17  
    18  func init() {
    19  	flag.BoolVar(&Build, "build", false, "build the compiled files only and exit")
    20  	flag.BoolVar(&NoCache, "no-cache", false, "disables the files cache")
    21  	flag.BoolVar(&OutputCmd, "output-cmd", false, "output compiler issued command to a file")
    22  	flag.StringVar(&ConfPath, "conf", "", "the config file")
    23  	flag.StringVar(&Port, "port", ":9810", "the port where the server will be listening")
    24  	flag.StringVar(&BuildTargets, "targets", "", "the targets to run/compile, separated by colon")
    25  }
    26  
    27  func IsTarget(name string) bool {
    28  	for _, t := range TargetList() {
    29  		if t == name {
    30  			return true
    31  		}
    32  	}
    33  	return false
    34  }
    35  
    36  func TargetList() []string {
    37  	return strings.Split(BuildTargets, ",")
    38  }
    39  
    40  func SelectTarget(target string) {
    41  	SelectedTarget = target
    42  }