map-dots/run/cli.go

88 lines
2.7 KiB
Go
Raw Normal View History

2023-08-11 14:32:44 +01:00
package run
2023-08-11 14:38:49 +01:00
import (
"fmt"
2023-08-11 14:53:28 +01:00
"image"
2023-08-11 14:38:49 +01:00
"os"
2023-08-11 14:53:28 +01:00
"git.fjla.uk/fred.boniface/map-dots/imaging"
"git.fjla.uk/fred.boniface/map-dots/log"
2023-08-11 14:38:49 +01:00
)
2023-08-11 14:32:44 +01:00
func CLI(height, width uint64, style, format, input string) {
2023-08-11 14:53:28 +01:00
log.Msg.Info("CLI Mode Started")
2023-08-11 14:32:44 +01:00
fmt.Printf("Running CLI mode with height=%d, width=%d, type=%s, input=%s\n", height, width, style, input)
fmt.Println("CLI Mode not implemented")
if input == "traccar" {
envCheck()
// Use traccar package to fetch data
// Pass fetched data to imageing package
}
// Check that `input` is a valid filepath and points to a valid file.
// Use relevent package to parse file
// Pass parsed data to imaging package
2023-08-11 14:53:28 +01:00
var testing []string
var _ image.Image = imaging.Generate(1, 1, "circle", "png", testing)
2023-08-11 14:32:44 +01:00
fmt.Println("End of implementation")
}
2023-08-11 14:38:49 +01:00
func HelpText() {
extendedHelp := `
map-dots - Transform location data into artistic heat-map style images
Usage:
map-dots [--server] [--height=HEIGHT] [--width=WIDTH] [--style=STYLE] [--format=FORMAT] [--input=INPUT] [--id=ID]
Options:
--server Run in server mode
--height=HEIGHT Output image height
--width=WIDTH Output image width
--style=STYLE Output image style
--format=FORMAT Output image format
--input=INPUT Input source
--id=ID Traccar device ID
More detailed help information:
-- server (Omit to run in CLI Mode):
Runs a web API on localhost:8198
Note that there is no authentication built in and the service could expose
personal location data if access is allowed from the internet.
-- height (Only in CLI Mode): DEFAULT: 1080
The height of the output image in pixels (Max: 7680)
-- width (Only in CLI Mode): DEFAULT: 1920
The width of the output image in pixels (Max: 4320)
-- style (Only in CLI Mode): DEFAULT: circles
The style of the output image - currently only 'circles' is available
-- format (Only in CLI Mode): DEFAULT: png
The image format of the output image. Options are:
png, jpeg, gif, bmp, tiff, webp
-- input (Only in CLI Mode): DEFAULT: traccar
The input source for data. Options are:
traccar, a valid file path in a supported format (See below for formats)
-- id (Only in CLI Mode): REQUIRED for CLI in 'traccar' mode
The Traccar device ID to fetch data for
If you want to fetch data from Traccar, you must ensure the following environment variables are set
This applies to Server and CLI modes:
TRACCAR_USER : Traccar Username
TRACCAR_PASS : Traccar Password
TRACCAR_URL : Traccar URL (Including port if not 80/443)
Input Formats:
Supported input file formats are:
xml+gpx, xml+kml, traccar-Api-JSON
For Web API usage information start the server and go to localhost:8198/help
`
fmt.Fprintf(os.Stderr, "%s\n", extendedHelp)
}