forked from fiam/max7456tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
100 lines (95 loc) · 2.48 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
package main
import (
"os"
"gopkg.in/urfave/cli.v1"
)
const (
defaultMargin = 1
defaultColumns = 16
)
var (
debugFlag = false
)
func main() {
app := cli.NewApp()
app.Version = "0.4"
app.Usage = "tool for managing .mcm character sets for MAX7456"
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "force, f",
Usage: "Overwrite output files without asking",
Destination: &forceFlag,
},
cli.BoolFlag{
Name: "debug, d",
Usage: "Print debug messages",
Destination: &debugFlag,
},
}
app.Commands = []cli.Command{
{
Name: "extract",
Usage: "Extract all characters to individual images",
ArgsUsage: "<input.mcm> <output-dir>",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "add-blanks, b",
Usage: "Include blank characters in the extracted files",
},
},
Action: extractAction,
},
{
Name: "build",
Usage: "Build a .mcm from the files in the given directory or .png file",
ArgsUsage: "<input> <output.mcm>",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "no-blanks, b",
Usage: "Don't fill missing characters with blanks (used only for directory input)",
},
cli.IntFlag{
Name: "margin, m",
Value: defaultMargin,
Usage: "Margin between each character (used only for image input)",
},
cli.IntFlag{
Name: "columns, c",
Value: defaultColumns,
Usage: "Number of columns in the output image (used only for image input)",
},
cli.StringFlag{
Name: "metadata, md",
Value: "",
Usage: "Metadata to add to the font. Metadata format is XXX=[(b|l)(i|u)(8|16|32|64):v]... where:\n" +
"\tXXX represents a character number\n" +
"\t(b|l)(i|u)(8|16|32|64) indicates the endianess, data type and bit size of the value\n" +
"\tv represents the value to encode\n" +
"\tValues encoded sequentially into the same character are separeted by ','" +
"\tMetadata characters are separated by '-'\n" +
"\tFor example: -md 255=lu8:3,li32:17-254=lu64:3",
},
},
Action: buildAction,
},
{
Name: "png",
Usage: "Generate a .png from an .mcm",
ArgsUsage: "<input.mcm> <output.png>",
Flags: []cli.Flag{
cli.IntFlag{
Name: "margin, m",
Value: defaultMargin,
Usage: "Margin between each character",
},
cli.IntFlag{
Name: "columns, c",
Value: defaultColumns,
Usage: "Number of columns in the output image",
},
},
Action: pngAction,
},
}
app.Run(os.Args)
}