(ctx context.Context, cla *FormatArgs)
| 46 | } |
| 47 | |
| 48 | func (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 | |
| 74 | func (*FormatCommand) Help() string { |
| 75 | helpText := ` |
no test coverage detected