more fixes to refactor
This commit is contained in:
parent
0062160581
commit
a93a45e4d3
|
@ -41,6 +41,9 @@ func ConfigType(args ...string) (string, error) {
|
|||
|
||||
// NewMetaArgs parses cli args and put possible values
|
||||
func (ma *MetaArgs) AddFlagSets(fs *flag.FlagSet) {
|
||||
if ma == nil {
|
||||
ma = &MetaArgs{}
|
||||
}
|
||||
fs.Var((*sliceflag.StringFlag)(&ma.Only), "only", "")
|
||||
fs.Var((*sliceflag.StringFlag)(&ma.Except), "except", "")
|
||||
fs.Var((*kvflag.Flag)(&ma.Vars), "var", "")
|
||||
|
@ -57,6 +60,9 @@ type MetaArgs struct {
|
|||
}
|
||||
|
||||
func (ba *BuildArgs) AddFlagSets(flags *flag.FlagSet) {
|
||||
if ba == nil {
|
||||
ba = &BuildArgs{}
|
||||
}
|
||||
flags.BoolVar(&ba.Color, "color", true, "")
|
||||
flags.BoolVar(&ba.Debug, "debug", false, "")
|
||||
flags.BoolVar(&ba.Force, "force", false, "")
|
||||
|
@ -83,6 +89,9 @@ type BuildArgs struct {
|
|||
type ConsoleArgs struct{ MetaArgs }
|
||||
|
||||
func (fa *FixArgs) AddFlagSets(flags *flag.FlagSet) {
|
||||
if fa == nil {
|
||||
fa = &FixArgs{}
|
||||
}
|
||||
flags.BoolVar(&fa.Validate, "validate", true, "")
|
||||
|
||||
fa.MetaArgs.AddFlagSets(flags)
|
||||
|
@ -95,6 +104,9 @@ type FixArgs struct {
|
|||
}
|
||||
|
||||
func (va *ValidateArgs) AddFlagSets(flags *flag.FlagSet) {
|
||||
if va == nil {
|
||||
va = &ValidateArgs{}
|
||||
}
|
||||
flags.BoolVar(&va.SyntaxOnly, "syntax-only", true, "")
|
||||
|
||||
va.MetaArgs.AddFlagSets(flags)
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"os"
|
||||
|
||||
kvflag "github.com/hashicorp/packer/helper/flag-kv"
|
||||
sliceflag "github.com/hashicorp/packer/helper/flag-slice"
|
||||
"github.com/hashicorp/packer/helper/wrappedstreams"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/hashicorp/packer/template"
|
||||
|
@ -80,19 +79,6 @@ func (m *Meta) Core(tpl *template.Template) (*packer.Core, error) {
|
|||
func (m *Meta) FlagSet(n string, fs FlagSetFlags) *flag.FlagSet {
|
||||
f := flag.NewFlagSet(n, flag.ContinueOnError)
|
||||
|
||||
// FlagSetBuildFilter tells us to enable the settings for selecting
|
||||
// builds we care about.
|
||||
if fs&FlagSetBuildFilter != 0 {
|
||||
f.Var((*sliceflag.StringFlag)(&m.CoreConfig.Except), "except", "")
|
||||
f.Var((*sliceflag.StringFlag)(&m.CoreConfig.Only), "only", "")
|
||||
}
|
||||
|
||||
// FlagSetVars tells us what variables to use
|
||||
if fs&FlagSetVars != 0 {
|
||||
f.Var((*kvflag.Flag)(&m.flagVars), "var", "")
|
||||
f.Var((*kvflag.StringSlice)(&m.varFiles), "var-file", "")
|
||||
}
|
||||
|
||||
// Create an io.Writer that writes to our Ui properly for errors.
|
||||
// This is kind of a hack, but it does the job. Basically: create
|
||||
// a pipe, use a scanner to break it into lines, and output each line
|
||||
|
|
Loading…
Reference in New Issue