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

Method ParseArgs

command/fmt.go:29–46  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

27}
28
29func (c *FormatCommand) ParseArgs(args []string) (*FormatArgs, int) {
30 var cfg FormatArgs
31 flags := c.Meta.FlagSet("format")
32 flags.Usage = func() { c.Ui.Say(c.Help()) }
33 cfg.AddFlagSets(flags)
34 if err := flags.Parse(args); err != nil {
35 return &cfg, 1
36 }
37
38 args = flags.Args()
39 if len(args) == 0 {
40 flags.Usage()
41 return &cfg, 1
42 }
43
44 cfg.Paths = args
45 return &cfg, 0
46}
47
48func (c *FormatCommand) RunContext(ctx context.Context, cla *FormatArgs) int {
49 if cla.Check {

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