-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
70 lines (60 loc) · 1.08 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
package main
import (
"fmt"
"log"
"os"
"path/filepath"
"github.com/mkideal/cli"
)
// Blueprint format.
type Blueprint struct {
Pixels []byte
Footer
}
type Footer struct {
HeightType int32 // Always 2s, probably data type with int32=2.
Height int32
WidthType int32
Width int32
BytesType int32
Bytes int32
LayerType int32
Layer int32
}
const (
LayerLogic = int32(65536)
LayerON = int32(131072)
LayerOFF = int32(262144)
)
const defaultOutputName = "blueprint.png"
var rootCmd = &cli.Command{
Desc: "Virtual Circuit Board blueprint tool by chrjen",
Text: fmt.Sprintf(`example: %s <command>`, filepath.Base(os.Args[0])),
Fn: func(ctx *cli.Context) error {
ctx.WriteUsage()
return nil
},
}
func ToLayer(l uint) int32 {
switch l {
case 0:
return LayerLogic
case 1:
return LayerON
case 2:
return LayerOFF
default:
return -1
}
}
func main() {
log.SetFlags(log.Lshortfile)
if err := cli.Root(rootCmd,
cli.Tree(decodeCmd),
cli.Tree(encodeCmd),
).Run(os.Args[1:]); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
os.Exit(0)
}