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

Method RunContext

command/fmt.go:48–72  ·  view source on GitHub ↗
(ctx context.Context, cla *FormatArgs)

Source from the content-addressed store, hash-verified

46}
47
48func (c *FormatCommand) RunContext(ctx context.Context, cla *FormatArgs) int {
49 if cla.Check {
50 cla.Write = false
51 }
52
53 formatter := hclutils.HCL2Formatter{
54 ShowDiff: cla.Diff,
55 Write: cla.Write,
56 Output: os.Stdout,
57 Recursive: cla.Recursive,
58 }
59
60 bytesModified, diags := formatter.Format(cla.Paths)
61 ret := writeDiags(c.Ui, nil, diags)
62 if ret != 0 {
63 return ret
64 }
65
66 if cla.Check && bytesModified > 0 {
67 // exit code taken from `terraform fmt` command
68 return 3
69 }
70
71 return 0
72}
73
74func (*FormatCommand) Help() string {
75 helpText := `

Callers 1

RunMethod · 0.95

Calls 2

FormatMethod · 0.95
writeDiagsFunction · 0.85

Tested by

no test coverage detected