| 22 | } |
| 23 | |
| 24 | func parseCommand() *command { |
| 25 | usage := `gcode. |
| 26 | |
| 27 | Usage: |
| 28 | gcode info <input> |
| 29 | gcode strip <input> <output> |
| 30 | gcode offset <input> <output> <x> <y> <z> |
| 31 | gcode svg <input> <output> |
| 32 | |
| 33 | Options: |
| 34 | -h --help Show this screen. |
| 35 | ` |
| 36 | |
| 37 | a, _ := docopt.Parse(usage, nil, true, "", false) |
| 38 | |
| 39 | return &command{ |
| 40 | // commands |
| 41 | cInfo: getBool(a["info"]), |
| 42 | cStrip: getBool(a["strip"]), |
| 43 | cOffset: getBool(a["offset"]), |
| 44 | cSVG: getBool(a["svg"]), |
| 45 | |
| 46 | // arguments |
| 47 | aInput: getString(a["<input>"]), |
| 48 | aOutput: getString(a["<output>"]), |
| 49 | aX: getFloat(a["<x>"]), |
| 50 | aY: getFloat(a["<y>"]), |
| 51 | aZ: getFloat(a["<z>"]), |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | func getBool(field interface{}) bool { |
| 56 | if val, ok := field.(bool); ok { |