start setting up to use flags
Signed-off-by: John Thornton <bjt128@gmail.com>
This commit is contained in:
36
dxf2gcode.go
36
dxf2gcode.go
@ -2,22 +2,41 @@ package main
|
||||
|
||||
// DXF to G code converter
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/jethornton/dxf2gcode/dxfutil"
|
||||
"os"
|
||||
"os/user"
|
||||
"github.com/jethornton/dxf2gcode/dxfutil"
|
||||
)
|
||||
|
||||
var (
|
||||
file *string
|
||||
port *int
|
||||
yesno *bool
|
||||
)
|
||||
|
||||
// Basic flag declarations are available for string, integer, and boolean options.
|
||||
func init() {
|
||||
file = flag.String("f", "/dxf/test.dxf", "Path to a DXF to convert")
|
||||
port = flag.Int("port", 3000, "an int")
|
||||
yesno = flag.Bool("yesno", true, "a bool")
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
usr, _ := user.Current() // get user information
|
||||
cwd, _ := os.Getwd() // get current working directory
|
||||
iniMap := make(map[string]string)
|
||||
var inFile string
|
||||
|
||||
if len(os.Args) == 2 {
|
||||
switch os.Args[1] {
|
||||
case "-v":
|
||||
fmt.Println("Version 0.001")
|
||||
os.Exit(0)
|
||||
case "-p":
|
||||
fmt.Println("-p")
|
||||
default:
|
||||
inFile = os.Args[1]
|
||||
}
|
||||
@ -31,26 +50,13 @@ func main() {
|
||||
dxfutil.Readini(iniMap, cwd)
|
||||
lines := dxfutil.GetLines(inFile)
|
||||
entities := dxfutil.GetEntities(lines)
|
||||
/*
|
||||
for _, e := range entities {
|
||||
fmt.Printf("%2d %4s G10 %8s G11 %8s G20 %8s G21 %8s G50 %9s G51 %9s\n",
|
||||
e.Test, e.G0, e.G10, e.G11, e.G20, e.G21, e.G50, e.G51)
|
||||
}
|
||||
*/
|
||||
entities = dxfutil.GetEndPoints(entities)
|
||||
/*
|
||||
for _, e := range entities {
|
||||
fmt.Printf("%2d %4s Xs %9f Ys %9f Xe %9f Ye %9f\n",
|
||||
e.Test, e.G0, e.Xs, e.Ys, e.Xe, e.Ye)
|
||||
}
|
||||
*/
|
||||
entities = dxfutil.GetOrder(entities)
|
||||
dxfutil.GenGcode(entities, iniMap["SAVEAS"])
|
||||
/*
|
||||
for _, e := range entities {
|
||||
fmt.Printf("%2d %2d %4s Xs %9f Xe %9f Ys %9f Ye %9f\n",
|
||||
e.Test, e.Index, e.G0, e.Xs, e.Xe, e.Ys, e.Ye)
|
||||
}
|
||||
*/
|
||||
dxfutil.GenGcode(entities, iniMap["SAVEAS"])
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user