MCPcopy
hub / github.com/hashicorp/packer / ParseArgs

Method ParseArgs

command/execute.go:89–105  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

87}
88
89func (c *ExecuteCommand) ParseArgs(args []string) (*ExecuteArgs, int) {
90 var cfg ExecuteArgs
91 flags := c.Meta.FlagSet("")
92 flags.Usage = func() { c.Ui.Say(c.Help()) }
93 cfg.AddFlagSets(flags)
94 if err := flags.Parse(args); err != nil {
95 return &cfg, 1
96 }
97
98 args = flags.Args()
99 if len(args) != 1 {
100 flags.Usage()
101 return &cfg, 1
102 }
103 cfg.CommandType = args[0]
104 return &cfg, 0
105}
106
107func (c *ExecuteCommand) Run(args []string) int {
108 cfg, ret := c.ParseArgs(args)

Callers 1

RunMethod · 0.95

Calls 5

HelpMethod · 0.95
AddFlagSetsMethod · 0.95
FlagSetMethod · 0.80
ParseMethod · 0.65
SayMethod · 0.45

Tested by

no test coverage detected