func main() {
	_, progName = filepath.Split(progName)
	if len(os.Args) == 1 {
		printUsage()
	}
	if _, err := os.Stat(mapDefinitionFile); err == nil {
		source, err := ioutil.ReadFile(mapDefinitionFile)
		if err != nil {
			log.Fatalf("error <%v> at ioutil.ReadFile(), file = <%s>", err, mapDefinitionFile)
		}
		err = yaml.Unmarshal(source, &mapConfig)
		if err != nil {
			log.Fatalf("error <%v> at yaml.Unmarshal()", err)
		}
	}
	fmt.Printf("\nurl = %v\n", mapConfig.ServiceURL)
	if _, err := os.Stat(mapIDFile); err == nil {
		filedata, err := ioutil.ReadFile(mapIDFile)
		if err != nil {
			log.Fatalf("error <%v> at ioutil.ReadFile(), file = <%s>", err, mapIDFile)
		}
		mapID = string(filedata)
	}
	fmt.Printf("map ID = %v\n", mapID)
	action := strings.ToLower(strings.Trim(os.Args[1], " ,"))
	fmt.Printf("action = %v\n", action)
	if action == "create" {
		checkMapDefinitionFile()
		create()
	} else if action == "update" {
		checkMapDefinitionFile()
		checkMapIDFile()
		update()
	} else if action == "upload" {
		checkMapDefinitionFile()
		checkMapIDFile()
		for _, file := range mapConfig.UploadFiles {
			upload(file)
		}
	} else if action == "state" {
		checkMapDefinitionFile()
		checkMapIDFile()
		fetch(action)
	} else if action == "order" {
		checkMapDefinitionFile()
		checkMapIDFile()
		order()
	} else if action == "download" {
		checkMapDefinitionFile()
		checkMapIDFile()
		download()
	} else if action == "data" {
		checkMapDefinitionFile()
		checkMapIDFile()
		fetch(action)
	} else if action == "delete" {
		checkMapDefinitionFile()
		checkMapIDFile()
		delete()
	} else if action == "capabilities" {
		fetch(action)
	} else if action == "unzip" {
		unzip()
	} else if action == "passepartout" {
		passepartout()
	} else if action == "rectangle" {
		rectangle()
	} else if action == "cropmarks" {
		cropmarks()
	} else if action == "latlongrid" {
		latlongrid()
	} else if action == "utmgrid" {
		utmgrid()
	} else if action == "latlon2utm" {
		latlon2utm()
	} else if action == "utm2latlon" {
		utm2latlon()
	} else if action == "bearingline" {
		bearingline()
	} else if action == "latlonline" {
		latlonline()
	} else if action == "utmline" {
		utmline()
	} else if action == "runlua" {
		runlua()
	} else {
		fmt.Printf("action <%v> not supported\n", action)
	}
	fmt.Printf("\n")
	os.Exit(0)
}
/*
main starts this program
package main
import (
	"archive/zip"
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"mime/multipart"
	"net/http"
	"net/http/httputil"
	"os"
	"path/filepath"
	"strconv"
	"strings"
	"github.com/StefanSchroeder/Golang-Ellipsoid/ellipsoid"
	"github.com/davecgh/go-spew/spew"
	"github.com/im7mortal/UTM"
	"github.com/paulmach/orb"
	"github.com/paulmach/orb/geojson"
	"github.com/printmaps/printmaps/pd"
	lua "github.com/yuin/gopher-lua"
	yaml "gopkg.in/yaml.v2"
)
var (
	progName    = os.Args[0]
	progVersion = "v0.7.0"
	progDate    = "2021/06/12"
	progPurpose = "Printmaps Command Line Interface Client"
	progInfo    = "Creates large-sized maps in print quality."
)
type MapConfig struct {
	ServiceURL  string      `yaml:"ServiceURL"`
	Metadata    pd.Metadata `yaml:"Metadata,inline"`
	UploadFiles []string    `yaml:"UserFiles"`
}
var mapConfig MapConfig
var mapID string
var (
	mapDefinitionFile = "map.yaml"
	mapIDFile         = "map.id"
)
var netClient = &http.Client{}
func init() {
	log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds | log.Lshortfile)
}