forked from clipperhouse/gen
/
list.go
48 lines (37 loc) · 768 Bytes
/
list.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
package main
import (
"fmt"
"github.com/clipperhouse/gen/typewriter"
)
func list() error {
imports := []string{
`"fmt"`,
`"os"`,
`"github.com/clipperhouse/gen/typewriter"`,
}
return execute(listStandard, imports, listBody)
}
func listStandard() error {
app, err := typewriter.NewApp("+gen")
if err != nil {
return err
}
fmt.Fprintln(out, "Installed typewriters:")
for _, tw := range app.TypeWriters {
fmt.Fprintf(out, " %s\n", tw.Name())
}
return nil
}
const listBody string = `
func main() {
app, err := typewriter.NewApp("+gen")
if err != nil {
os.Stderr.WriteString(err.Error() + "\n")
os.Exit(1)
}
fmt.Println("Installed typewriters (custom):")
for _, tw := range app.TypeWriters {
fmt.Println(" " + tw.Name())
}
}
`