-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
51 lines (46 loc) · 1001 Bytes
/
main.go
File metadata and controls
51 lines (46 loc) · 1001 Bytes
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"encoding/json"
"fmt"
"log"
"os"
"sort"
"github.com/nullstone-io/module/config"
"github.com/urfave/cli"
)
func main() {
var dir string
app := &cli.App{
Commands: []cli.Command{
{
Name: "manifest",
Description: `This generates a nullstone module manifest from a directory of terraform files.`,
Flags: []cli.Flag{
cli.StringFlag{
Name: "dir",
Usage: "Directory to scan. By default, uses current directory.",
Value: ".",
Destination: &dir,
},
},
Action: func(c *cli.Context) error {
cfg, err := config.ParseDir(dir)
if err != nil {
return err
}
manifest := cfg.ToManifest()
raw, _ := json.MarshalIndent(manifest, "", " ")
fmt.Println(string(raw))
return nil
},
},
},
}
sort.Sort(cli.FlagsByName(app.Flags))
sort.Sort(cli.CommandsByName(app.Commands))
err := app.Run(os.Args)
if err != nil {
log.Fatalln(err)
}
os.Exit(0)
}