forked from jessfraz/dockfmt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdump.go
31 lines (24 loc) · 811 Bytes
/
dump.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"context"
"flag"
"fmt"
"github.com/moby/buildkit/frontend/dockerfile/parser"
)
const dumpHelp = `Dump parsed Dockerfile(s).`
func (cmd *dumpCommand) Name() string { return "dump" }
func (cmd *dumpCommand) Args() string { return "[OPTIONS] DOCKERFILE [DOCKERFILE...]" }
func (cmd *dumpCommand) ShortHelp() string { return dumpHelp }
func (cmd *dumpCommand) LongHelp() string { return dumpHelp }
func (cmd *dumpCommand) Hidden() bool { return false }
func (cmd *dumpCommand) Register(fs *flag.FlagSet) {}
type dumpCommand struct{}
func (cmd *dumpCommand) Run(ctx context.Context, args []string) error {
return forFile(args, func(f string, nodes []*parser.Node) error {
fmt.Println(f)
if len(nodes) > 0 {
fmt.Println(nodes[0].Dump())
}
return nil
})
}