-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
executable file
·108 lines (94 loc) · 2.45 KB
/
main.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package main
import (
"flag"
"os"
"github.com/gokit/assetkit/generators"
"github.com/influx6/faux/flags"
"github.com/influx6/moz/ast"
)
func main() {
flags.Run("assetkit", flags.Command{
Name: "public",
ShortDesc: "Generates bundling for public files",
Desc: "Generates asset bundling for standard public static files",
Action: func(ctx flags.Context) error {
force := ctx.GetBool("force")
name := flag.Arg(1)
currentdir, err := os.Getwd()
if err != nil {
return err
}
commands, err := generators.TrailPackages(
ast.AnnotationDeclaration{Arguments: []string{name}},
ast.PackageDeclaration{FilePath: currentdir},
ast.Package{},
)
if err != nil {
return err
}
return ast.SimpleWriteDirectives("", force, commands...)
},
Flags: []flags.Flag{
&flags.BoolFlag{
Name: "force",
Desc: "force regeneration of packages annotation directives.",
},
},
},
flags.Command{
Name: "view",
ShortDesc: "Generates bundling with a html file",
Desc: "Generates asset bundling isolated view package",
Action: func(ctx flags.Context) error {
force := ctx.GetBool("force")
name := flag.Arg(1)
currentdir, err := os.Getwd()
if err != nil {
return err
}
commands, err := generators.TrailView(
ast.AnnotationDeclaration{Arguments: []string{name}},
ast.PackageDeclaration{FilePath: currentdir},
ast.Package{},
)
if err != nil {
return err
}
return ast.SimpleWriteDirectives("", force, commands...)
},
Flags: []flags.Flag{
&flags.BoolFlag{
Name: "force",
Desc: "force regeneration of packages annotation directives.",
},
},
},
flags.Command{
Name: "static",
Desc: "Generates bundling for general static files",
ShortDesc: "Generates bundling general use case static files",
Action: func(ctx flags.Context) error {
force := ctx.GetBool("force")
name := flag.Arg(1)
currentdir, err := os.Getwd()
if err != nil {
return err
}
commands, err := generators.TrailFiles(
ast.AnnotationDeclaration{Arguments: []string{name}},
ast.PackageDeclaration{FilePath: currentdir},
ast.Package{},
)
if err != nil {
return err
}
return ast.SimpleWriteDirectives("", force, commands...)
},
Flags: []flags.Flag{
&flags.BoolFlag{
Name: "force",
Desc: "force regeneration of packages annotation directives.",
},
},
})
}