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

Function processFiles

cmd/hclfmt/main.go:80–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78}
79
80func processFiles() error {
81 if flag.NArg() == 0 {
82 if *overwrite {
83 return errors.New("error: cannot use -w without source filenames")
84 }
85
86 return processFile("<stdin>", os.Stdin)
87 }
88
89 for i := 0; i < flag.NArg(); i++ {
90 path := flag.Arg(i)
91 switch dir, err := os.Stat(path); {
92 case err != nil:
93 return err
94 case dir.IsDir():
95 // This tool can't walk a whole directory because it doesn't
96 // know what file naming schemes will be used by different
97 // HCL-embedding applications, so it'll leave that sort of
98 // functionality for apps themselves to implement.
99 return fmt.Errorf("can't format directory %s", path)
100 default:
101 if err := processFile(path, nil); err != nil {
102 return err
103 }
104 }
105 }
106
107 return nil
108}
109
110func processFile(fn string, in *os.File) error {
111 var err error

Callers 1

realmainFunction · 0.85

Calls 1

processFileFunction · 0.85

Tested by

no test coverage detected