v.io/jiri@v0.0.0-20160715023856-abfb8b131290/profiles/flags.go (about)

     1  // Copyright 2015 The Vanadium Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package profiles
     6  
     7  import "flag"
     8  
     9  const (
    10  	targetDefValue = "<runtime.GOARCH>-<runtime.GOOS>"
    11  )
    12  
    13  // RegisterTargetAndEnvFlags registers the commonly used --target and --env
    14  // flags with the supplied FlagSet
    15  func RegisterTargetAndEnvFlags(flags *flag.FlagSet, target *Target) {
    16  	*target = DefaultTarget()
    17  	flags.Var(target, "target", target.Usage())
    18  	flags.Lookup("target").DefValue = targetDefValue
    19  	flags.Var(&target.commandLineEnv, "env", target.commandLineEnv.Usage())
    20  }
    21  
    22  // RegisterTargetFlag registers the commonly used --target flag with
    23  // the supplied FlagSet.
    24  func RegisterTargetFlag(flags *flag.FlagSet, target *Target) {
    25  	*target = DefaultTarget()
    26  	flags.Var(target, "target", target.Usage())
    27  	flags.Lookup("target").DefValue = targetDefValue
    28  }