MCPcopy
hub / github.com/hashicorp/hcl / main

Function main

cmd/hcldec/main.go:47–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45}
46
47func main() {
48 flag.Usage = usage
49 flag.Parse()
50
51 if *showVersion {
52 fmt.Println(versionStr)
53 os.Exit(0)
54 }
55
56 args := flag.Args()
57
58 switch *diagsFormat {
59 case "":
60 color := term.IsTerminal(int(os.Stderr.Fd()))
61 w, _, err := term.GetSize(int(os.Stdout.Fd()))
62 if err != nil {
63 w = 80
64 }
65 diagWr = hcl.NewDiagnosticTextWriter(os.Stderr, parser.Files(), uint(w), color)
66 case "json":
67 diagWr = &jsonDiagWriter{w: os.Stderr}
68 default:
69 fmt.Fprintf(os.Stderr, "Invalid diagnostics format %q: only \"json\" is supported.\n", *diagsFormat)
70 os.Exit(2)
71 }
72
73 err := realmain(args)
74
75 if err != nil {
76 fmt.Fprintf(os.Stderr, "Error: %s\n\n", err.Error())
77 os.Exit(1)
78 }
79}
80
81func realmain(args []string) error {
82

Callers

nothing calls this directly

Calls 4

FilesMethod · 0.80
realmainFunction · 0.70
ExitMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected